Advertisement
sujonshekh

Fibonacci With function

Aug 12th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include<stdio.h>
  2. int fibonacci(int n)
  3. {
  4.     if(n==1 || n==2)
  5.     return 1;
  6.     else
  7.         return fibonacci(n-1)+fibonacci(n-2);
  8. }
  9.  
  10. int main()
  11. {
  12.     int n;
  13.  
  14.     scanf("%d",&n);
  15.     fibonacci(n);
  16.     printf("Fibonachi = %d",fibonacci(n));
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement