Recursion: computing $f(3^{100})$

49 Views Asked by At

Given the function $f:N^+ \rightarrow N$ such that: $f(2^n)=n^2$, $f(3n)=f(2n)+5$, Find the value of $f(3^{100})$:

I tried calculating some smaller $f(3^k)$ for integer $k$, to look for a pattern, If I haven't done silly mistakes I got:$$f(3)=6,f(3^2)=9,f(3^3)=24,f(3^4)=36$$ I noticed that $f(3)\cdot4=f(3^3)$ and $f(3^2)\cdot4=f(3^4)$, nonetheless, I don't think this kind of pattern holds, I wrote in general that: $$f(3\cdot2^n)=n^2+2n+6$$ Hints or partial help is much appreciated!

1

There are 1 best solutions below

2
On BEST ANSWER

You can easily show by induction that for all $n \in \lbrace 0, ..., 100 \rbrace$, $$f(3^{100})=f(2^n \times 3^{100-n}) + 5n$$

Using that with $n=100$, you get $$f(3^{100}) = f(2^{100}) + 500 = 100^2+ 500 = 10500$$