خرید بک لینک

Vote count: 0

So I am trying to create a function that takes amount, percentage(decimal) and times and retus a double with the amount.

The result I expect is the following:

$amount = 10000
$percentage = 1.1
$times = 1

so..

elevateToPercentage($amount, $percentage, $times) = 10,000 * 1.1 = 11,000
$times = 2
elevateToPercentage($amount, $percentage, $times) = ((10,000 * 1.1) * 1.1) = 12,100
$times = 4
elevateToPercentage($amount, $percentage, $times) = ((((10,000 * 1.1) * 1.1) * 1.1) * 1.1) = 14,641

private function elevateToPercentage($amount, $percentage, $times) {
    $count  = 0;
    for( $a = 0; $a <= $times; $a++ ) {
        $count += ($amount * $percentage);
    }
    retu $count;
}

I know this is a logic error but I´ve been up too much and I don't seem to work anymore right now :( can you guys please help me out ?

Thank you!

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 26 خرداد 1395 ساعت: 1:54

صفحه بندی