172 words
1 minutes
sum_of_digits
2026-08-27

I recently came across a quite interesting short math question. The question goes:

The problem#

Find the sum of the digits of N2N^2, where

N=888⋯8⏟2025 digits.N=\underbrace{888\cdots 8}_{2025\text{ digits}}.

The solution#

The nice part of this problem is that we can set it up nicely such that the number is split into two blocks whose digit sums complement each other.

First, we have

N=89(102025−1).N=\frac{8}{9}(10^{2025}-1).

Since 2025=9⋅2252025=9\cdot225, the number 102025−110^{2025}-1 is divisible by 109−1=99999999910^9-1=999999999, which is also divisible by 8181. Therefore, we may know that

φ=6481(102025−1)\varphi=\frac{64}{81}(10^{2025}-1)

is an integer. We also have 0<φ<1020250<\varphi<10^{2025}. Using this auxiliary number, we can rewrite the square as

N2=6481(102025−1)2=φ(102025−1)=(φ−1)102025+(102025−φ).\begin{aligned} N^2 &=\frac{64}{81}(10^{2025}-1)^2\\ &=\varphi(10^{2025}-1)\\ &=(\varphi-1)10^{2025}+(10^{2025}-\varphi). \end{aligned}

Because 0<102025−φ<1020250<10^{2025}-\varphi<10^{2025}, this expression places φ−1\varphi-1 in the left block and 102025−φ10^{2025}-\varphi in the right block, padding the right block with leading zeros if needed. The blocks do not overlap, so their digit sums simply add.

Let S(x)S(x) denote the sum of the decimal digits of xx. Then

S(N2)=S(φ−1)+S(102025−φ).S(N^2)=S(\varphi-1)+S(10^{2025}-\varphi).

Furthermore, notice that

S(φ−1)=S(φ)−1.S(\varphi-1)=S(\varphi)-1.

Hence

102025−φ=(102025−1)−(φ−1).10^{2025}-\varphi=(10^{2025}-1)-(\varphi-1).

Since the terms are set up so nicely, we now have

S(102025−φ)=9⋅2025−S(φ−1)=9⋅2025−S(φ)+1.\begin{aligned} S(10^{2025}-\varphi) &=9\cdot2025-S(\varphi-1)\\ &=9\cdot2025-S(\varphi)+1. \end{aligned}

Adding the two digit sums makes the unknown terms cancel:

S(N2)=(S(φ)−1)+(9⋅2025−S(φ)+1)=9⋅2025=18225.\begin{aligned} S(N^2) &=\bigl(S(\varphi)-1\bigr) +\bigl(9\cdot2025-S(\varphi)+1\bigr)\\ &=9\cdot2025\\ &=\boxed{18225}. \end{aligned}
sum_of_digits
https://mashiroisasleep.github.io/posts/problems/sum_of_digits/
Author
Mashiro
Published at
2026-08-27