<?php
homoCredit(40000);
function homoCredit($cost) {
$balance=0;
$total=0;
for ($i=1; $balance > 0; $i++) {
$balance=$cost*1.04+500;
if ($balance >= 5000) {
$balance -= 5000;
$total += $i*5000;
}
else {
$total += $balance;
$balance = 0;
}
}
echo "$total";
return $total;
}
/*$cost=39999;
$homoCreditTotal = homoCredit($cost);
echo "homocredit - $homoCreditTotal"; */
PD9waHAKaG9tb0NyZWRpdCg0MDAwMCk7CmZ1bmN0aW9uIGhvbW9DcmVkaXQoJGNvc3QpIHsKCSRiYWxhbmNlPTA7CgkkdG90YWw9MDsKCWZvciAoJGk9MTsgJGJhbGFuY2UgPiAwOyAkaSsrKSB7CgkJJGJhbGFuY2U9JGNvc3QqMS4wNCs1MDA7CgkJaWYgKCRiYWxhbmNlID49IDUwMDApIHsKCQkJJGJhbGFuY2UgLT0gNTAwMDsKCQkJJHRvdGFsICs9ICRpKjUwMDA7CgkJfQoJCWVsc2UgewoJCQkkdG90YWwgKz0gJGJhbGFuY2U7CgkJCSRiYWxhbmNlID0gMDsKCQl9Cgl9CgllY2hvICIkdG90YWwiOwoJcmV0dXJuICR0b3RhbDsKfQoKLyokY29zdD0zOTk5OTsKJGhvbW9DcmVkaXRUb3RhbCA9IGhvbW9DcmVkaXQoJGNvc3QpOwplY2hvICJob21vY3JlZGl0IC0gJGhvbW9DcmVkaXRUb3RhbCI7ICov