fork download
  1. #include <iostream>
  2.  
  3. int fib(int n)
  4. {
  5. return n > 1 ? fib(n-1) + fib(n-2) : 1;
  6. }
  7.  
  8. int main(int argc, char* argv[])
  9. {
  10. std::cout << fib(1) << std::endl;
  11. std::cout << fib(10) << std::endl;
  12.  
  13. return 0;
  14. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
1
89