A video went viral recently showing a neat math trick:
Take a number, find its nth root, and check if that equals the digit sum minus n.
The original showed just 4 examples:
| Expression | Digit Sum − n | Result |
|---|---|---|
| √25 = 5 | (2+5) − 2 = 5 | ✅ |
| √64 = 8 | (6+4) − 2 = 8 | ✅ |
| ³√125 = 5 | (1+2+5) − 3 = 5 | ✅ |
| ³√4096 = 16 | (4+0+9+6) − 3 = 16 | ✅ |
Cool party trick. But as a developer, my first thought was: are there more?
Brute-Forcing the Answer
I wrote a simple script to check every combination:
def digit_sum(n):
return sum(int(d) for d in str(n))
solutions = []
for n in range(2, 20): # root degree (2=square, 3=cube...)
for number in range(1, 1_000_000): # check up to 1 million
root = round(number ** (1/n))
# Verify it is a perfect nth root
if root ** n != number:
continue
# Check the pattern: nth_root == digit_sum - n
if root == digit_sum(number) - n:
solutions.append((n, number, root))
print(f"{n}root({number}) = {root} "
f"(digit sum {digit_sum(number)} - {n} = {root})")
The Results: 8 Total Solutions
The original video found 4. We found 8:
2-digit numbers (square roots)
√25 = 5 → (2+5) − 2 = 5 ✅
√64 = 8 → (6+4) − 2 = 8 ✅
3-digit numbers (square + cube roots)
³√125 = 5 → (1+2+5) − 3 = 5 ✅
√196 = 14 → (1+9+6) − 2 = 14 ✅ ← NEW!
√289 = 17 → (2+8+9) − 2 = 17 ✅ ← NEW!
4-digit numbers (cube roots only)
³√2744 = 14 → (2+7+4+4) − 3 = 14 ✅ ← NEW!
³√3375 = 15 → (3+3+7+5) − 3 = 15 ✅ ← NEW!
³√4096 = 16 → (4+0+9+6) − 3 = 16 ✅
That is it. No 5-digit solutions. No 4th roots. No 5th roots. The pattern completely dies.
Why Does It Die?
Here is the intuition:
- An n-digit number has a maximum digit sum of 9n (all 9s)
- A k-digit number is at least 10^(k-1)
- For the pattern to work:
nth_root ≈ digit_sum − n
As numbers grow, the nth root grows polynomially but the digit sum grows only logarithmically (roughly proportional to the number of digits).
The gap between them widens fast:
Number | Max Digit Sum | Square Root
-----------:|:-------------:|:---------:
99 | 18 | ~10
999 | 27 | ~32
9,999 | 36 | ~100
99,999 | 45 | ~316
999,999 | 54 | ~1000
By 5 digits, the square root is already 7× larger than the maximum possible digit sum. The pattern mathematically cannot produce new solutions.
The Takeaway
This is why I love code. A viral video shows a cute trick with 4 examples and implies it is a deep pattern. Ten lines of Python proves there are exactly 8 solutions and the pattern is finite.
Not everything that looks like a pattern is a pattern. But finding the boundaries is where the real fun starts.
▶️ Watch the YouTube Short: https://youtube.com/shorts/ocnOgIYSDdE
I also made a YouTube Short about this — check it out above! 👆
Like mathematical puzzles + code? Follow me for more — I post daily about AI, development, and the occasional number theory rabbit hole.
Top comments (0)