Advertisement
Vasilena

PracticeDayThreeExercise5

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