fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int Fibonacci(int n)
  5. {
  6. if ( n == 0 )
  7. return 0;
  8. else if ( n == 1 )
  9. return 1;
  10. else
  11. return ( Fibonacci(n-1) + Fibonacci(n-2) );
  12. }
  13.  
  14. int main() {
  15. // your code goes here
  16. int n;
  17. scanf("%d",&n);
  18. printf("%d",Fibonacci(n));
  19. return 0;
  20. }
Success #stdin #stdout 0s 3464KB
stdin
6
stdout
8