DEV Community

Discussion on: Daily Challenge #271 - Simulate Population Growth

Collapse
 
peter279k profile image
peter279k

Here is my solution with PHP code snippets:

function nbYear($p0, $percent, $aug, $p) {
  $percent = $percent / 100;
  $entry = 0;
  while ($p0 < $p) {
    $p0 = $p0 + $p0 * $percent + $aug;
    $entry += 1;
  }

  return $entry;
}