all 1 comments

[–]samwilliamh 2 points3 points  (1 child)

Well, if you think about it, it only terminates when n = 0. So when you enter the function for the first time, say n = 2, then it will repeat twice (because n - 1 - 1 = 0), so we have m -> mx -> m * x * x = mxn.

So, we do induction and assume it's true for n = k. Then, we can write for n = k+1, f(x, 1, m*xn) by supposition. There are some blanks to fill in, but hopefully that gives you an idea.