/*
* sum of square of natural number
* */
$n = 5;
$sum = 0;
$i = 1;
while($n){
$i = $n;
$sum += $i ** 2;
$n--;
}
echo $sum;
/*
* sum of square of natural number in another way
* */
$n = 5;
$sum = 0;
$i = 1;
while($n){
$sum += ($n * $n);
$n--;
}
echo $sum;
* sum of square of natural number
* */
$n = 5;
$sum = 0;
$i = 1;
while($n){
$i = $n;
$sum += $i ** 2;
$n--;
}
echo $sum;
/*
* sum of square of natural number in another way
* */
$n = 5;
$sum = 0;
$i = 1;
while($n){
$sum += ($n * $n);
$n--;
}
echo $sum;
No comments:
Post a Comment