incrementing in php
Posted: Fri Apr 25, 2008 6:29 am
How can I create an application that will display perfect numbers from 1-100? The output should be 1 3 6 10 15 21 28.... Notice that the difference between the numbers are 2 3 4 5 6 7....
<?php
$one=0;
$two=1;
for ($x=0;$x<=45;$x++){
echo $nxt." ";
$cur=$one;
$nxt=$two;
$sum=$cur+$nxt;
$two=$sum;
}
?>
<?php
$one=0;
$two=1;
for ($x=0;$x<=45;$x++){
echo $nxt." ";
$cur=$one;
$nxt=$two;
$sum=$cur+$nxt;
$two=$sum;
}
?>