Hi, could someone please explain to me how the following code results in 24, i understood it in class but totally forgot now and i have a mid term tomorrow. Please help. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
using std::cout;
using std::endl;
int rose(int n);
//precondition: n >= 0
int main()
{
cout << rose(4) << endl;
return 0;
}
int rose(int n)
{
if (n <= 0)
return 1;
elsereturn (rose(n - 1)*n);
}