Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. <body>
  2.  
  3. <form>
  4. <input type="text" name="liczba">
  5. <input type="submit" value="oblicz"><br><br>
  6. </form>
  7.  
  8. <?php
  9.  
  10. $n = 1;
  11.  
  12. if (isset($_GET['liczba'])) {
  13. $n = $_GET['liczba'];
  14. }
  15.  
  16. if ($n <= 2)
  17. print($n . ' elementem ciagu Fibonaciego jest 1');
  18. else {
  19. $f1 = 1;
  20. $f2 = 1;
  21. $wyn = 1;
  22. for ($i = 3; $i <= $n; $i++) {
  23. $wyn = $f1 + $f2;
  24. $f1 = $f2;
  25. $f2 = $wyn;
  26. }
  27. print($n . ' elementem ciagu Fibonaciego jest ' . $f2);
  28. }
  29.  
  30.  
  31. ?>
  32. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement