Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int recursive(unsigned int n);
  7.  
  8. int main()
  9. {
  10. int recNum = -1;
  11. while (recNum < 0)
  12. {
  13. cout << "Please enter a positive integer: ";
  14. cin >> recNum;
  15. }
  16. cout << "Result: " << recursive(recNum) << endl;
  17.  
  18. system("pause");
  19. return 0;
  20. }
  21.  
  22. int recursive(unsigned int n)
  23. {
  24. if ((n / 3) < 1)
  25. {
  26. return n;
  27. }
  28. return n * recursive(n / 3);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement