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 c79034c commit 3f9ec25Copy full SHA for 3f9ec25
maths/disarium.py
@@ -0,0 +1,21 @@
1
+def is_disarium(num: int) -> bool:
2
+ """
3
+ Check if a number is Disarium.
4
+
5
+ >>> is_disarium(89)
6
+ True
7
+ >>> is_disarium(75)
8
+ False
9
+ >>> is_disarium(135)
10
11
12
+ digits = list(str(num))
13
+ total = 0
14
+ for i in range(len(digits)):
15
+ total += int(digits[i]) ** (i + 1)
16
+ return total == num
17
18
19
+if __name__ == "__main__":
20
+ import doctest
21
+ doctest.testmod(verbose=True)
0 commit comments