Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int fib_worker(int a, int b, int n)
  4. {
  5. if (n == 0) return a;
  6.  
  7. return fib_worker(b, a+b, n - 1);
  8. }
  9.  
  10. int fibonacci(int n)
  11. {
  12. return fib_worker(0, 1, n);
  13. }
  14.  
  15. int main()
  16. {
  17. printf("%d\n", fibonacci(45));
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement