Guest User

Untitled

a guest
Feb 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Pascal's Triangle</title>
  5. </head>
  6. <body>
  7.  
  8. <?php
  9. if (isset($_REQUEST["lines"]) && int($_REQUEST["lines"]) > 0)
  10. {
  11. print "<pre>";
  12.  
  13. $line = Array(1);
  14.  
  15. for ($i = 0; $i < int($_REQUEST["lines"]); $i++)
  16. {
  17. print implode(' ', $line)."\n";
  18. $line[] = 0;
  19. for ($n = count($line) - 1; $n >= 1; $n--)
  20. $line[$n] += $line[$n - 1];
  21. }
  22.  
  23. print "</pre>";
  24. print "<hr>";
  25. }
  26. ?>
  27.  
  28. <form action="#" method="POST">
  29. Number of lines: <input type="text" name="lines">
  30. <input type="submit" value="Go">
  31. </form>
  32.  
  33. </body>
  34. </html>
Add Comment
Please, Sign In to add comment