Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- using namespace std;
- int recursive(unsigned int n);
- int main()
- {
- int recNum = -1;
- while (recNum < 0)
- {
- cout << "Please enter a positive integer: ";
- cin >> recNum;
- }
- cout << "Result: " << recursive(recNum) << endl;
- system("pause");
- return 0;
- }
- int recursive(unsigned int n)
- {
- if ((n / 3) < 1)
- {
- return n;
- }
- return n * recursive(n / 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement