<?php
$credit = 1000 ;
$percent = 0.03 ;
$commission = 1000 ;
$payment = 5000 ;
$rate = 1 + $percent ;
do {
$credit = $credit * $rate + $commission ;
$log .= "Current month sum: $credit \n " ;
$credit -= $payment ;
$log .= "Sum, after anon paid: $credit \n " ;
$period ++;
$log .= "Current month $period \n \n " ;
} while ( ( $credit * $rate + $commission ) > $payment ) ;
$credit = $credit * $rate + $commission ;
$log .= "Current month sum: $credit \n " ;
$sum = $period * $payment + $credit ;
$credit = 0 ;
$period ++;
$log .= "Sum, after anon paid: $credit \n " . "Current month $period \n \n " ;
echo "Anon paid for $period month. \n Whole sum: $sum .\n Credit: $credit \n \n " ;
echo $log ;
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CiAKJGNyZWRpdCA9IDEwMDA7CiRwZXJjZW50ID0gMC4wMzsKJGNvbW1pc3Npb24gPSAxMDAwOwokcGF5bWVudCA9IDUwMDA7CiAKJHJhdGUgPSAxICsgJHBlcmNlbnQ7CiAKZG8gewogICAgJGNyZWRpdCA9ICRjcmVkaXQgKiAkcmF0ZSArICRjb21taXNzaW9uOwogICAgJGxvZyAuPSAiQ3VycmVudCBtb250aCBzdW06ICRjcmVkaXQgXG4iOwogCiAgICAkY3JlZGl0IC09ICRwYXltZW50OwogICAgJGxvZyAuPSAiU3VtLCBhZnRlciBhbm9uIHBhaWQ6ICRjcmVkaXQgXG4iOwogCiAgICAkcGVyaW9kKys7CiAgICAkbG9nIC49ICJDdXJyZW50IG1vbnRoICRwZXJpb2RcblxuIjsKIAp9IHdoaWxlICgoJGNyZWRpdCAqICRyYXRlICsgJGNvbW1pc3Npb24pID4gJHBheW1lbnQpOwoKJGNyZWRpdCA9ICRjcmVkaXQgKiAkcmF0ZSArICRjb21taXNzaW9uOwogCiRsb2cgLj0gIkN1cnJlbnQgbW9udGggc3VtOiAkY3JlZGl0IFxuIjsKIAokc3VtID0gJHBlcmlvZCAqICRwYXltZW50ICsgJGNyZWRpdDsKJGNyZWRpdCA9IDA7CiRwZXJpb2QrKzsKIAokbG9nIC49ICJTdW0sIGFmdGVyIGFub24gcGFpZDogJGNyZWRpdFxuIi4iQ3VycmVudCBtb250aCAkcGVyaW9kXG5cbiI7CiAKZWNobyAiQW5vbiBwYWlkIGZvciAkcGVyaW9kIG1vbnRoLiBcbiBXaG9sZSBzdW06ICRzdW0uXG4gQ3JlZGl0OiAkY3JlZGl0IFxuXG4iOwplY2hvICRsb2c7