Is there a general formula to calculate the n-th digit of any big number?
-
1You mean, other than actually multiplying? As a general rule, probably not. But the question you asked in your title can be solved. Which question do you want answered? (Your question should always be in the body, not just the title.) – Thomas Andrews Oct 20 '13 at 13:13
-
For the title question, you want $3^{100}$ mod $100$, which can be done easily if you know how. For the question in the body, as Thomas said, the answer is "no". – GEdgar Oct 20 '13 at 13:16
-
The general formula was my dream and there is an answer in my question . Check it please http://math.stackexchange.com/questions/141919/digit-function-properties – Mathlover Oct 20 '13 at 13:16
3 Answers
Following the question in the title,
$$3^{100}=9^{50}=(10-1)^{50}\equiv\binom{50}210^2-\binom{50}110+1\pmod{1000}$$
Now, $$\binom{50}210^2-\binom{50}110=\frac{50\cdot49}210^2-500$$ $$=2500\cdot49-500=2500\cdot48+(2500-500)\equiv0\pmod{1000}$$
Alternatively, using Carmichael function, $\lambda(1000)=100$

- 274,582
$3^{100}=81^{25}=(80+1)^{25}=(8\cdot10+1)^{25}=\sum_{k=0}^{25}C_{25}^k\cdot80^k=1\cdot1+25\cdot80+\ldots=1+2000+\ldots\rightarrow3^{100}\mod10^3=1\rightarrow\text{its last three digits are 001}.$

- 48,334
- 2
- 83
- 154
We would like to calculate $3^{100}\pmod{100}$. This will tell us the last two digits of $3^{100}$, which includes the tens digit.
We proceed as follows: $3^4 = 81$, so:
$$\begin{align} 3^8 & \equiv (81)^2 \equiv 61 \pmod{100} \\ 3^{16} & \equiv (61)^2 \equiv 21\pmod{100} \\ 3^{24} & \equiv 61\cdot 21 \equiv 81\pmod{100}\\ 3^{48} & \equiv (81)^2 \equiv 61 \pmod{100} \\ 3^{50} & \equiv 9\cdot 61 \equiv 49\pmod{100} \\ 3^{100} & \equiv (49)^2\equiv 01 \pmod {100} \end{align}$$
So the last two digits are 01
.
In general it's very quick to calculate $a^b\pmod n$. You calculate $a^{\lfloor b/2 \rfloor}\pmod n$ (using this method recursively if necessary) and square it, again mod $n$; if $b$ is odd you multiply the result by $a$ and you are done.

- 65,394
- 39
- 298
- 580