fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int f(int n){
  6.  
  7. if(n > 1){
  8. return f(n-1) + f(n-2);
  9. }
  10. if(n == 1){
  11. return 1;
  12. }
  13. if(n == 0){
  14. return 1;
  15. }
  16.  
  17. }
  18.  
  19. int main(){
  20.  
  21. int n;
  22. cin >> n;
  23.  
  24. cout << f(n) << "\n";
  25. }
Success #stdin #stdout 0s 5280KB
stdin
4
stdout
5