Recursive function that doubles its input

177 Views Asked by At

The conditions of finding this function this function is to not use the operation (+) and (*) we are only allowed to use the successor ($S_n$), i.e. $S_1 = 2$.

I was able to find the Base case which is: $d(0) = 0$,

$d$ is the function's name. For the step case I found an expression, however, there is no recursion in my step case which should use the function $d$ again

My Step Case: $d(n) = S_1S_2S_3S_n(n)$

any help is appreciated, thank you

1

There are 1 best solutions below

0
On BEST ANSWER

When thinking about the recursive step you have to ask yourself "If I knew how to do the 'n' case could I work out the 'n+1' case?". So starting with $2(n+1)$ you can expand it to $2(n+1) = 2n + 2$ which allows you to write your recursive step.

$$ d(S(n)) = S(S(d(n)) $$