# Field Manual for Hackers

## php - Write a program using while loop to calculate and print the first ‘N’ Ex=10 Fibonacci number starts with (1,1),2, 3,5,8,13,21,34,55

1. \$num1=\$_POST["num"];
\$i=2;
\$first=1;
\$second=1;
echo "\$first \$second";
while(\$i!=\$num1)
{
\$third=\$first+\$second;
\$first=\$second;
\$second=\$third;
echo " \$third";
\$i++;
}

2. php
\$n=\$_POST['num'];
\$count=\$n;
\$first=1;
\$second=1;
\$i=2;
echo" the number of digit is:\$count";
echo"\$first\t\$second";
while(\$i<\$n)
{\$next=\$first+\$second;
\$first=\$second;
\$second=\$next;
echo"
\$next\t";
\$i++;
}
?>

3. This comment has been removed by the author.

4. \$num=\$_POST["n"];
\$i=2;
\$n1=1;
\$n2=1;
echo "\$n1 \$n2";
while(\$i!=\$num)
{
\$n3=\$n1+\$n2;
\$n1=\$n2;
\$n2=\$n3;
echo " \$n3";
\$i++;
}

5. ?php
\$nos=\$_POST["num"];
\$first=0;
\$second=1;
\$third=0;
\$i=1;
echo"\$first, "." \$second, ";
while(\$i<=\$nos)
{
\$third=\$first+\$second;
\$i++;
\$first=\$second;
\$second=\$third;
echo"\$third,";
}
?>