<?php
function Credit($credit, $pay, $percent, $tax, $payForBill) {
$total = 0;
$credit += $payForBill;
while ($credit > 0) {
$credit = $credit * $percent + $tax;
if ($credit < $pay) {
$total += $credit;
break;
}
else {
$credit -= $pay;
$total += $pay;
}
}
return $total;
}
$creditSum = 39999;
$payout = 5000;
$homoCreditTotal = Credit($creditSum, $payout, 1.04, 500, 0);
$softbankTotal = Credit($creditSum, $payout, 1.03, 1000, 0);
$strawberryBankTotal = Credit($creditSum, $payout, 1.02, 0, 7777);
echo "homoCredit: {$homoCreditTotal}\n";
echo "softbank: {$softbankTotal}\n";
echo "strawberryBank: {$strawberryBankTotal}\n";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7CgpmdW5jdGlvbiBDcmVkaXQoJGNyZWRpdCwgJHBheSwgJHBlcmNlbnQsICR0YXgsICRwYXlGb3JCaWxsKSB7CgkkdG90YWwgPSAwOwoJJGNyZWRpdCArPSAkcGF5Rm9yQmlsbDsKCXdoaWxlICgkY3JlZGl0ID4gMCkgewoJCQoJCSRjcmVkaXQgPSAkY3JlZGl0ICogJHBlcmNlbnQgKyAkdGF4OwoJCQoJCWlmICgkY3JlZGl0IDwgJHBheSkgewoJCQkkdG90YWwgKz0gJGNyZWRpdDsKCQkJYnJlYWs7CgkJfQoJCWVsc2UgewoJCQkkY3JlZGl0IC09ICRwYXk7CgkJCSR0b3RhbCArPSAkcGF5OwoJCX0KCX0KCXJldHVybiAkdG90YWw7Cn0KCiRjcmVkaXRTdW0gPSAzOTk5OTsKJHBheW91dCA9IDUwMDA7CiRob21vQ3JlZGl0VG90YWwgPSBDcmVkaXQoJGNyZWRpdFN1bSwgJHBheW91dCwgMS4wNCwgNTAwLCAwKTsKJHNvZnRiYW5rVG90YWwgPSBDcmVkaXQoJGNyZWRpdFN1bSwgJHBheW91dCwgMS4wMywgMTAwMCwgMCk7CiRzdHJhd2JlcnJ5QmFua1RvdGFsID0gQ3JlZGl0KCRjcmVkaXRTdW0sICRwYXlvdXQsIDEuMDIsIDAsIDc3NzcpOwoKZWNobyAiaG9tb0NyZWRpdDogeyRob21vQ3JlZGl0VG90YWx9XG4iOwplY2hvICJzb2Z0YmFuazogeyRzb2Z0YmFua1RvdGFsfVxuIjsKZWNobyAic3RyYXdiZXJyeUJhbms6IHskc3RyYXdiZXJyeUJhbmtUb3RhbH1cbiI7