/*
* sum of natural number
* */
$x = 8;
$result = $x;
while($x--){
$result += $x;
}
echo $result;
/*
* sum of natural number in another way
* */
$x = 8;
$result = 0;
while($x){
$result += $x--;
}
echo $result;
* sum of natural number
* */
$x = 8;
$result = $x;
while($x--){
$result += $x;
}
echo $result;
/*
* sum of natural number in another way
* */
$x = 8;
$result = 0;
while($x){
$result += $x--;
}
echo $result;
No comments:
Post a Comment