Problem: How to add numbers between 1 to 100?
This obey arithmetic sequence. Mathematical formula wise this is 100*(1+100)/2=1050. Here is details.
Let see how to implement this in PHP.
function sum( $n, $a1, $a2 ) { return $n * ( $a1 + $a2 ) / 2; } echo 'Total=' . sum( 100, 1, 100 );