Pattern visualizer
Check Armstrong Number
A number is an Armstrong number when the sum of its own digits, each raised to the power of the digit count, reconstructs the original number. For 153's three digits, that means summing each digit cubed and checking it lands back on 153. Animated on: n = 153 — check whether n equals the sum of its own digits, each raised to the digit-count's power..
Sum each digit cubed, compare to the original
time O(d)space O(1)step 1 / 9
1
[0]5
[1]3
[2]line 2
153 has 3 digits: 1, 5, 3. Check whether 1^3 + 5^3 + 3^3 equals 153.
Pseudocode
1FUNCTION isArmstrong(n):2 digits = the digits of n3 sum = 04 FOR each digit d in digits:5 add d cubed to sum6 RETURN true if sum equals n, otherwise false
← / → step · space play · Home restart