Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|cite|improve this question
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|cite|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|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.