loulett

HW1_fibb_rec

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