Paste Search Dynamic
Recent pastes
Fibonacci series
  1. <?php
  2. extract($_REQUEST);
  3. if(isset($check))
  4. {
  5. $num = 0;  
  6. $n1 = 0;  
  7. $n2 = 1;  
  8. echo "<h3>Fibonacci series for first $n numbers: </h3>";  
  9. echo "n";  
  10. echo $n1.' '.$n2.' ';  
  11. while ($num < $n-2 )  
  12. {  
  13.     $n3 = $n2 + $n1;  
  14.     echo $n3.' ';  
  15.     $n1 = $n2;  
  16.     $n2 = $n3;  
  17.     $num = $num + 1;  
  18. }
  19. }
  20. ?>
  21. <!DOCTYPE html>
  22. <html>
  23.         <head>
  24.                 <title>Fibonacci Series</title>
  25.         </head>
  26.         <body>
  27.                 <form method="post">
  28.                 <table>
  29.                 <tr>
  30.                 <td>Enter Your Number</td>
  31.                 <td><input type="text" name="n" required/></td>
  32.                 </tr>
  33.                 <td colspan="2" align="center">
  34.                         <input type="submit" value="Print Fibonacci Series" name="check"/>
  35.                 </tr>
  36.                 </form>
  37.         </body>
  38. </html>
  39. </html>
  40.  
Parsed in 0.025 seconds