etonw

recursive fibonacci function

May 31st, 2022 (edited)
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1. // recursive fibonacci function
  2. int fibonacci (int n)    
  3. {
  4.     if (  (n==0) || (n==1)  )  {
  5.         return 1;
  6.     } else {
  7.         return fibonacci (n-1) + fibonacci (n-2);    
  8.     }
  9. }
Add Comment
Please, Sign In to add comment