Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Pascal's Triangle</title>
- </head>
- <body>
- <?php
- if (isset($_REQUEST["lines"]) && int($_REQUEST["lines"]) > 0)
- {
- print "<pre>";
- $line = Array(1);
- for ($i = 0; $i < int($_REQUEST["lines"]); $i++)
- {
- print implode(' ', $line)."\n";
- $line[] = 0;
- for ($n = count($line) - 1; $n >= 1; $n--)
- $line[$n] += $line[$n - 1];
- }
- print "</pre>";
- print "<hr>";
- }
- ?>
- <form action="#" method="POST">
- Number of lines: <input type="text" name="lines">
- <input type="submit" value="Go">
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment