Write a PHP program to make the sum of first 100 odd numbers

Write a PHP program to make the sum of first 100 odd numbers.


In this tutorial, you will be learning how to find sum of first 100 odd numbers in php also call it as find the sum of odd numbers within a given range.

Below is the php script to find the sum of first 100 odd numbers.

<?php
    $sum=0;

    for($i=1;$i<=200;$i+=2)
    {
        $sum+=$i;
    }

    echo "the total sum of 100 odd numbers: $sum";
?>


Thanks for reading.