<?php
function credit($commission, $percent, $creditSum, $payout){
for ($i=0; $creditSum > 0; $i++) {
$creditSum =($creditSum * $percent) + $commission;
if($creditSum< $payout){
$payout = $creditSum;
$creditSum = $creditSum - $payout;
break;
}elseif($creditSum >= $payout ){
$creditSum = $creditSum -$payout;
}
}
}
return;
$balance = credit(500,0.04,39999,5000);
echo "{$balance}";
PD9waHAKCmZ1bmN0aW9uIGNyZWRpdCgkY29tbWlzc2lvbiwgJHBlcmNlbnQsICRjcmVkaXRTdW0sICRwYXlvdXQpewoJZm9yICgkaT0wOyAkY3JlZGl0U3VtID4gMDsgJGkrKykgewoJJGNyZWRpdFN1bSA9KCRjcmVkaXRTdW0gKiAkcGVyY2VudCkgKyAkY29tbWlzc2lvbjsKCSAgaWYoJGNyZWRpdFN1bTwgJHBheW91dCl7CiAKCSAJJHBheW91dCA9ICRjcmVkaXRTdW07CgkgJGNyZWRpdFN1bSA9ICRjcmVkaXRTdW0gLSAkcGF5b3V0OwoJIAkKCSAJYnJlYWs7CiAKCSB9ZWxzZWlmKCRjcmVkaXRTdW0gPj0gJHBheW91dCApewogCgkgCSRjcmVkaXRTdW0gPSAkY3JlZGl0U3VtIC0kcGF5b3V0OwogCgoKIAoJCX0KCQkKCX0KCQoJCn0KIHJldHVybjsKJGJhbGFuY2UgPSBjcmVkaXQoNTAwLDAuMDQsMzk5OTksNTAwMCk7CgllY2hvICJ7JGJhbGFuY2V9Ijs=