fork download
  1. <?php
  2.  
  3. function calculateCredit($percent, $commission, $years, $creditSum, $payout, $downPayment){
  4. $creditSum += $downPayment;
  5. $totalPaid = 0;
  6. for($i=0; $i<$years; $i++){
  7. $creditSum = ($creditSum * $percent + $commission);
  8. if($creditSum > $payout){
  9. $creditSum -= $payout;
  10. $totalPaid += $payout;
  11. }
  12. else{$totalPaid += $creditSum; $creditSum -= $creditSum; break;}
  13. }
  14. return $totalPaid;
  15. }
  16.  
  17. $homoCreditTotal = calculateCredit(1.04, 500, 15, 39999, 5000, 0);
  18. $softbankTotal = calculateCredit(1.03, 1000, 15, 39999, 5000, 0);
  19. $strawberryBankTotal = calculateCredit(1.02, 0, 15, 39999, 5000, 7777);
  20.  
  21. echo "homoCredit: {$homoCreditTotal} руб.\n";
  22. echo "softbank: {$softbankTotal} руб. \n";
  23. echo "strawberryBank: {$strawberryBankTotal} руб. \n";
Success #stdin #stdout 0.02s 24508KB
stdin
Standard input is empty
stdout
homoCredit: 56423.563121625 руб.
softbank: 61268.718210807 руб. 
strawberryBank: 53559.8738592 руб.