fork download
  1. #include <iostream>
  2. using namespace std;
  3. int factorial(int n){
  4. //base case
  5. if(n==0)
  6. return 1;
  7.  
  8.  
  9. int smaller=factorial(n-1);
  10. int bigger=2*smaller;
  11. return bigger;//2*factorial(n-1);
  12.  
  13. }
  14.  
  15. int main() {
  16. // your code goes here
  17. int n;
  18. cin>>n;
  19. int ans=factorial(n);
  20. cout<<ans<<endl;
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5516KB
stdin
5
stdout
32