Advertisement
hpolzer

Fibonacci numbers (bc)

Apr 19th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. /*
  2. Compute (huge) Fibonacci numbers using bc,
  3. Henning Polzer, 19. April 2015
  4. */
  5.  
  6. define fibonacci (z) {
  7.  
  8. if (z < 1) return 0 else
  9. if (z < 3) return 1
  10.  
  11. m = n = 1
  12.  
  13. for (i = 2; i < z; i++) {
  14. summe = m + n
  15. m = n
  16. n = summe
  17. }
  18.  
  19. return summe
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement