Question: Given the following function int Ulam(int num) { if (num <2) return 1; else if (num %2 ==0) return Ulam(num/2); else return Ulam(3* num +1);

Given the following function

int Ulam(int num)

{

if (num <2)

return 1;

else if (num %2 ==0)

return Ulam(num/2);

else

return Ulam(3* num +1);

}

a.What problems come up in verifiying this function?

b.How many recursive calls are made by the following initial calls?

cout << Ulam(7) <

cout << Ulam(8) <

cout << Ulam(15) << endl;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!