<?php

error_reporting(-1);

function getTotalCreditSum ($creditSum, $creditFee, $percent, $singlePayment, $monthlyPayment) {
	$creditSum = $creditSum + $singlePayment;
	for ($monthCount = 1; $monthCount < 30; $monthCount++) {
		$creditSum = $creditSum + $creditFee + $creditSum*$percent - $monthlyPayment;
		if ($creditSum <= 0) {
			break;
		}
	}
	$totalCreditSum = $monthlyPayment*$monthCount - $creditSum;
	return $totalCreditSum;
}
$totalPaymentOfHomoCredit = getTotalCreditSum(39999, 500, 0.04, 0, 5000);
echo "{$totalPaymentOfHomoCredit}\n";
$totalPaymentOfSoftbank = getTotalCreditSum(39999, 1000, 0.03, 0, 5000);
echo "{$totalPaymentOfSoftbank}\n";
$totalPaymentOfStrawberryBank = getTotalCreditSum(39999, 0, 0.02, 7777, 5000);
echo "{$totalPaymentOfStrawberryBank}\n";