0

i cant stop the loop

<?PHP $p=24000000; $y=1990; $r=0.035; $ny=$y++; $count=1; while($p<50000000){ $np=$p+($p*$r); $y=$y+1 /*calculate the rate of growth of population in a year*/; echo "iteration # $count.<h5>thepopulation willbe<em>$np</em>ni year<u>$y</u></h5>"/; $count++;} echo "<br/><br/><h2>the populatuon will be<Mem>$np</em>in year <u>$y</u></h2>"/*print the year that the population reached 50000000 and stop*/ ; ?> WHY DOES'NT IT STOP

4th Nov 2017, 6:36 PM
Luqman Mussa
Luqman Mussa - avatar
6 Respuestas
+ 9
You haven't changed $p inside the loop if I'm seeing right. So $p will remain less than 50000000 forever and loop will run 🏃 forever :)
4th Nov 2017, 6:55 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 3
The same, $p not appear into while and always have the same initial value
4th Nov 2017, 7:01 PM
Daniel
Daniel - avatar
+ 2
what is $p and what is $np? if you use $p for the while then you must to write something to increase to arrive sometime to break condition
7th Nov 2017, 7:50 PM
Daniel
Daniel - avatar
+ 1
Maybe you must to fix $np=$p+($p*$r) per $p=$p+($p*$r)
7th Nov 2017, 9:20 PM
Daniel
Daniel - avatar
0
so what should I change
7th Nov 2017, 7:17 PM
Luqman Mussa
Luqman Mussa - avatar