fork download
  1. <?php
  2.  
  3. function getCreditPayment($current, $percent, $service) {
  4. $payed = 0;
  5. $monthlyPayment = 5000;
  6. for ($i = 0; $current > 0; $i++) {
  7. $current = $current*$percent + $service - $monthlyPayment;
  8. $payed += $monthlyPayment;
  9. if ($current < 0) {
  10. $payed += $current;
  11. }
  12. }
  13. return ceil($payed);
  14. }
  15.  
  16. $totalHomoCredit = getCreditPayment(39999, 1.04, 500);
  17. $totalSoftbank = getCreditPayment(39999, 1.03, 1000);
  18. $totalStrawberryBank = getCreditPayment(39999+7777, 1.02, 0);
  19.  
  20. echo "HomoCredit: {$totalHomoCredit}\n";
  21. echo "Softbank : {$totalSoftbank}\n";
  22. echo "StrawberryBank: {$totalStrawberryBank}";
  23. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
HomoCredit: 56424
Softbank : 61269
StrawberryBank: 53560