The code uses CodeByMath's built-in
digit_sum(n) function to calculate the sum of all digits in an integer (e.g.
digit_sum(98989) is $9+8+9+8+9 = 43$).
The code has
???? for checking divisibility by 11. Replace
???? with
11 and click
Run Code to inspect which of the 15 five-digit numbers are divisible by 11!
Notice that exactly 3 of them end up divisible by 11: $97999$, $98989$, and $99979$.
Check out the examples below to see the alternating sum rule in action and explore other digit-sum divisibility puzzles!