Docsity

Recursive Function 'mystery' and its Computation - Prof. Marjory Baruch, Lab Reports of Computer Science

Partial preview of the text

Download Recursive Function 'mystery' and its Computation - Prof. Marjory Baruch and more Lab Reports Computer Science in PDF only on Docsity!

Figure 10.2 from Hanley and Koffman (modified) int mystery(int m, int n) { int ans; if (n == 1) /* simple case / ans = m; else / recursive step */ ans = m + mystery(m, n-1); return (ans); } compute mystery(5, 4); Notice m stays the same. Recursion is on n, which is 4 in our example Make a table m n mystery(m,n)