by CodeChum Admin
A mitosis program has gone out of hand and now does abnormal cell duplication. Rather than scrapping the project, the researchers decided to observe and predict the cell duplication using a program.
Instructions:
Input
1. Base integer
2. Initial factor
3. Number of times to process
Output
Enter·base·integer:·3
Enter·initial·factor:·2
Enter·number·of·times·to·process:·3
Result·=·54#include <iostream>
using namespace std;
int GetResult(int base, int factor, int times)
{
	while (times > 0)
	{
		base *= factor;
		times -= 1;
		return GetResult(base, factor, times);
	}
	return base;
}
int main()
{
	int base, factor, times;
	cout << "Please, enter base integer: ";
	cin >> base;
	cout << "Please, enter factor integer: ";
	cin >>factor;
	cout << "Please, enter times integer: ";
	cin >> times;
	cout << "Result = " << GetResult(base, factor, times);
}
Comments