1 return 1 now evaluates to 2 else return anint

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ng factorial(2) factorial(4) an_int 4 factorial(3) an_int 3 factorial(2) an_int 2 if (an_int <= 1): Now evaluates to 1 return 1 else: return an_int * factorial(an_int – 1) Now evaluates to 2 * 1 16 Exi,ng factorial(2) factorial(4) an_int 4 factorial(3) an_int 3 factorial(2) an_int 2 2 if (an_int <= 1): return 1 else: return an_int * factorial(an_int – 1) 17 Exi,ng factorial(3) factorial(4) an_int 4 factorial(3) an_int 3 if (an_int <= 1): return 1 Now evaluates to 2 else: return an_int * factorial(an_int – 1) Now evaluates to 3 * 2 18 6 13 ­11 ­04 Exi,ng factorial(3) factorial(4) an_int factorial(3) 4 an_int 3 6 if (an_int <= 1): return 1 else: return an_int * factorial(an_int – 1) 19 Exi,ng factorial(4) factorial(4) an_int 4 So 24 is returned to the code which made the original call: if (an_int <= 1): return 1 Now evaluates to 6 else return an_int * factorial(an_int –...
View Full Document

Ask a homework question - tutors are online