Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body>
- <form>
- <input type="text" name="liczba">
- <input type="submit" value="oblicz"><br><br>
- </form>
- <?php
- $n = 1;
- if (isset($_GET['liczba'])) {
- $n = $_GET['liczba'];
- }
- if ($n <= 2)
- print($n . ' elementem ciagu Fibonaciego jest 1');
- else {
- $f1 = 1;
- $f2 = 1;
- $wyn = 1;
- for ($i = 3; $i <= $n; $i++) {
- $wyn = $f1 + $f2;
- $f1 = $f2;
- $f2 = $wyn;
- }
- print($n . ' elementem ciagu Fibonaciego jest ' . $f2);
- }
- ?>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement