DoubleOseven - 8 months ago 46

C++ Question

I am trying to create a recursive function as follows.

The function takes a counter

`k`

`result = 2(2(2n+1)+1)+1`

where the last n (when k=0) should be zero.

`int pass(int k, int n)`

{

if(k==0)

{

n = 0;

}

else

{

k--;

return pass(k, 2*n+1);

}

}

Can someone give me a hint as on how to do it?

Source (Stackoverflow)