That code looks to be a snipper from a recursive function, which calculates the x^n.

What it does is you call the first function, with 2^3 say.

It returns 2*2^2, then to work out 2^2 it calls the same function with that, so it returns 2*2^1, and that returns 2*2^0. 2^0 is then returned 1 by the special case, so it collapses to 2*(2*(2*(1))).

I would have just used a loop as I tend to prefer iterative over recursive solutions.

Code:`for(int n=0;n<power;n++)`

num *= 2;