Assume that the functions CS303 and UMKC have been defined as follows:
int CS303(int n) {
if (n <= 0) {
return 1;
} else {
return UMKC(5, CS303(n - 5));
}
}
int UMKC(int n1, int n2) {
if (n1 == 0) {
return 0;
} else {
return n2 + UMKC(n1/5, n2);
}
}
What is the value of CS303(20)?
16
#include <iostream> using namespace std; int UMKC(int n1, int n2) { if (n1 == 0) { return 0; } else { return n2 + UMKC(n1 / 5, n2); } } int CS303(int n) { if (n <= 0) { return 1; } else { return UMKC(5, CS303(n - 5)); } } int main() { cout << CS303(20) << endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.