CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

Recursive Example:

Factorial

long fac(long n)
{
long result;
if(n==0) return 1;
result= n*fac(n-1);
return result;
}
void mainprog()
{
Box result("Result:");
result.say(fac(3));
}
 

How many times will "fac" be called? Trace it!!!

What values will "n" have?

What values will "result" have?