Web Hosting Talk







View Full Version : PHP Exponential growth


Justin M
07-13-2008, 05:56 PM
Ok, so I've got this small program:

<?php

for($level = 100; $turns <= 100;)
{
$points += ($level * 1.15);
echo $points . "<br />";
$turns++;
}

?>

Only I'm having a mindblock as how to make it exponentially increase instead of linear. Thanks for the help. :)

bigfan
07-13-2008, 08:40 PM
This will exponentially increase $points, from a starting value equal to $level, over 100 iterations:$level = 100;
for ($points = $level, $turns = 0; $turns < 100; $turns++) {
$points *= 1.15;
echo $points . '<br />';
}