fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int fib(int n)
  5. {
  6. if(n<=0)
  7. {
  8. return 0;
  9. }
  10. if(n==1 || n==2)
  11. {
  12. return 1;
  13. }
  14. return fib(n-1) + fib(n-2);
  15. }
  16. int main() {
  17. // your code goes here
  18. cout<<fib(5);
  19. return 0;
  20. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
5