1134. Armstrong Number

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1134

class Solution:
    def isArmstrong(self, n: int) -> bool:
        k = len(str(n))
        s, x = 0, n
        while x:
            s += (x % 10) ** k
            x //= 10
        return s == n