Advertisement
Tariqul_Islam

Resursive fibonacci

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