Please see my comment to the question.
I basically answered you about stack; will also add this: a function parameters are put on the stack, and they disappear with the frame when function returns. But of course, you need to learn seriously how stack, stack frames and calls work, this is one of the most fundamental basics of programming. But your question does not provide any adequate sample for the study of it, except the work "recursion", so there is nothing else to explain.
See also:
https://en.wikipedia.org/wiki/Call_stack[
^].
Now, your real problem is that you don't even try to use the value of
n
.
All you need to solve your problem is
bitwise operators, and a loop:
https://en.wikipedia.org/wiki/Bitwise_operations_in_C[
^],
http://www.cprogramming.com/tutorial/bitwise_operators.html[
^].
—SA