## Sum of Natural Numbers in PHP

Sum of Natural Numbers in PHP <?php $n=5; // Initialises n to 10 for sum of natural no. up to 10 $sum=0; for($i=1;$i<= $n; $i++) { $sum = $sum +$i; // This statement execution i will explain below } echo $sum; ?> // First iteration, $sum=0 and $i=1 on the right side then left side … Read more Sum of Natural Numbers in PHP