How would one go about finding the last four digits of this sum?

167 Views Asked by At

So I was looking through the homepage of Youtube when I found this video by Cipher. The question proposed in the video was$$\text{How do I find the last }4\text{ digits of the sum of }2+22+222+2222+\dots+\underbrace{222\dots222}_{1042\text{ digits}}\text{?}$$which I thought that I might be able to solve. Here is my attempt at solving the aforementioned question:$$\text{First step: Find a pattern in the first four digits}$$$$2$$$$24$$$$246$$$$2468$$$$4690$$$$6912$$$$9134$$$$1356$$$$3578$$$$5800$$$$8022$$$$0244$$$$2466$$As you can see:$$\text{Term }4\text{: }2468$$$$\text{Term }13\text{: }2466$$$$13-4=9\text{ terms between the first term that contains }4\text{ digits and the next term that follows a pattern}$$$$\text{Therefore every }9\text{ terms the last }4\text{ digits will be }2\text{ less than the last term in the pattern.}$$$$\text{Therefore we need to do}$$$$\left\lfloor\frac{2042-13}{9}\right\rfloor$$Which simplifies to$$225\text{ and a remainder of }4$$Which means we now need to go back $4$ terms in the sequence from term $13$ and then subtract $500$ from that, and we get$$3578-500=3078$$

Therefore, the last four digits of the sum of$$2+22+222+2222+\dots+\underbrace{222\dots222}_{1042\text{ digits}}$$Is 3078.$$\mathbf{\text{My question}}$$


Is the solution that I achieved correct, or what could I do to attain the correct solution/attain it more easily?

3

There are 3 best solutions below

0
On BEST ANSWER

Adding up the digits with the same place value gives

$$\begin{array}{ccccccccc} & 2 & 2 & 2 & \cdots & 2 & 2 & 2 & 2 \\ & & 2 & 2 & \cdots & 2 & 2 & 2 & 2 \\ & & & 2 & \cdots & 2 & 2 & 2 & 2 \\ & & & & \ddots & \vdots & \vdots & \vdots & \vdots\\ & & & & & 2 & 2 & 2 & 2 \\ & & & & & & 2 & 2 & 2 \\ & & & & & & & 2 & 2 \\ + & & & & & & & & 2 \\ \hline & 2\times1 & 2\times2 & 2\times3 & \cdots & 2\times1039 & 2\times1040 & 2\times1041 & 2\times1042 \end{array}$$

i.e. a number in base $10$ whose $(10^{n-1})$s value is $2\times(1042-n)$ $(n\ge1)$. A proper number in base $10$ has digits that do not exceed $9$. To make this number proper, carry over the excess to the next place value. Looking at only the last four place values, we have

$$\begin{align*} \cdots[2078][2080][2082][2084] &= \cdots[2078][2080][2082][2084] \\ &= \cdots[2078][2080][2082+208]\color{red}{4} \\ &= \cdots[2078][2080][2290]4 \\ &= \cdots[2078][2080+229]\color{red}{0}4 \\ &= \cdots[2708][2309]04 \\ &= \cdots[2708+230]\color{red}{9}04 \\ &= \cdots[2938]904 \\ &= \cdots\boxed{\color{red}{8}904} \end{align*}$$

0
On

To answer your questions:

  1. In your approach, instead of 2042, you should be using 1042. That's the only error you made. With that, you get 8904 as shown below.
  2. A slightly simpler approach is to find $ 2 + 22 + 222 + (1042-3) \times 2222 \pmod{10000}$ like lulu mentioned.

Your approach is to find $2 + 22 + 222 + 2222 + 2222 + 2222 + \ldots + 2222 \pmod{10000}$.
You already made the observation that $ 9 \times 2222 \equiv -2 \pmod{10000}$.
So, what we want is $ 2 + 22 + 222 + \lfloor \frac{ 1042 - 3 } { 9} \rfloor \times ( - 2 ) + 9\times \{ \frac{1042-3}{9} \} \times 2222 \pmod{10000}$.
(I chose to use "-3" because that is the start of the pattern. We could take "-4" or "-13" as desired, and just ensure we account for the number of terms correctly.)
This is equal to $8904 \pmod{10000}$.

0
On

The easiest way to see this, in my opinion, is just to look at the last four digits and compute the sum for those: $2+22+222+2222\cdot1039=2308904 $. This is feasible for this case, because the result is small. For a larger calculation, you can do what other users have commented. So, the solution is $8904$, as evidenced by the value below.

It is easy to right a program to calculate this sum. In Python, it looks like this:

s=0
for k in range(1,1043):
    n=0
    for j in range(0,k):
        n=2*10**j+n
    s=s+n
print(s)

The solution is: $$2469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802469135802468904 $$