fork download
  1. <?php
  2.  
  3.  
  4. function calcCreditSum($creditPerc, $commission, $price, $pay) {
  5.  
  6.  
  7. for ($i=0; $i < 20; $i++) {
  8.  
  9. $price += $price * $creditPerc / 100 + $commission;
  10.  
  11. if($price <= $pay){
  12.  
  13. break;
  14. }
  15. $price += $perc - $pay;
  16. }
  17.  
  18. $price += $i*$pay;
  19. return $price;
  20. }
  21.  
  22. function calcCreditSumPzdc($creditPerc, $commission, $price, $pay) {
  23.  
  24. $price += $commission;
  25.  
  26. for ($i=0; $i < 20; $i++) {
  27.  
  28. $price += $creditPerc * $price / 100;
  29.  
  30. if ($price <= $pay){
  31.  
  32. break;
  33. }
  34.  
  35. $price -= $pay;
  36.  
  37. }
  38.  
  39. $price += $i*$pay;
  40. return $price;
  41. }
  42.  
  43. $pay = 5000;
  44. $price = 39999;
  45.  
  46. $balance = calcCreditSum(4, 500, $price, $pay);
  47. echo "Hmcrdt: {$balance}\n";
  48.  
  49. $balance = calcCreditSum(3, 1000, $price, $pay);
  50. echo "yobabank: {$balance}\n";
  51.  
  52. $balance = calcCreditSum(2, 0, $price + 7777, $pay);
  53. echo "pzdc: {$balance}\n";
Success #stdin #stdout #stderr 0.02s 24400KB
stdin
Standard input is empty
stdout
Hmcrdt: 56423.563121625
yobabank: 61268.718210807
pzdc: 53559.8738592
stderr
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16
PHP Notice:  Undefined variable: perc in /home/4FqCgr/prog.php on line 16