We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c88735 commit c395b3bCopy full SHA for c395b3b
maths/armstrong_number.py
@@ -0,0 +1,16 @@
1
+def is_armstrong(number: int) -> bool:
2
+ """
3
+ Check if a number is an Armstrong number.
4
+
5
+ >>> is_armstrong(153)
6
+ True
7
+ >>> is_armstrong(123)
8
+ False
9
10
+ digits = list(map(int, str(number)))
11
+ power = len(digits)
12
+ return sum(d ** power for d in digits) == number
13
14
15
+if __name__ == "__main__":
16
+ print(is_armstrong(153))
0 commit comments