Take the 2-minute tour ×

Given the following function $f$
$f(n)=11\cdot f(n-1)+2^{n-1}$

I would like to compute $f(13^{17})\mod 10^9$ and ended up using the following :

$f(n)=\sum_{i=0}^{n-1}({11^{n-(i+1)}\cdot 2^i})$

though I am able to quickly compute a single term using modular exponentiation, the loop over $13^{17}-1$ takes ages.

So do you have any suggestion to simplify $f(n)$ to avoid the loop ?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Note that $f(n)$ may be simply rewritten as $\displaystyle f(n)=\frac{11^n-2^n}{11-2}$

share|improve this answer
Now it becomes easy as pie :) thank you ! –  hoang Jul 5 '12 at 14:46
@hoang: fine! :-) –  Raymond Manzoni Jul 5 '12 at 14:46
@hoang, how did you calculate $2^{{13}^{17}}(mod\ 10^9)$ –  lab bhattacharjee Jul 7 '12 at 7:34

Clearly $f(n)$ will be of the form $a \cdot 11^n+b \cdot 2^n$ where $a,b$ are integers. Given $f(1)=1$, but $f(1)=11a+2b$. Similarly $f(2)=11f(1)+2=13$, but $f(2)=121a+4b$.

Solving for $a,b$, we get $f(n)= \frac{11^n-2^n}9$.


$11^{13^{17}} = (10+1)^{13^{17}}=1+{13^{17}} \cdot 10^{13^{17}} + \dots \equiv 1 \pmod {10^{13^{17}}} \equiv 1 \pmod{10^9}$

Let $2^{13^{17}} \equiv c \pmod{10^9} = k10^9+c$

Clearly,$\left(2^{13^{17}},\ 10^9\right)\bigg|c \Rightarrow c$ is of the form $2^9d \Rightarrow 2^{13^{17}-9} \equiv d \pmod{2^9}$

As $2$ is a primitive root of $5$ and of $5^2$ ,s o it'll be of $5^n$, $n \geq 1$. $\phi(5^9)=4 \cdot 5^8$.

So, taking discrete logarithm in base $2$, ${13^{17}-9} \equiv \operatorname{ind}_2d \pmod{4 \cdot 5^8}$ =>$\operatorname{ind}_2d\equiv{(13^{17}-9)}\pmod {4 \cdot5^8}$.

and so on.

share|improve this answer

Your Answer


