Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions maths/disarium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# disarium.py


def is_disarium(num):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: is_disarium. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: num

"""
Check if a number is Disarium.

>>> is_disarium(89)
True
>>> is_disarium(75)
False
>>> is_disarium(135)
True
"""
digits = list(str(num))
total = 0
for i in range(len(digits)):
total += int(digits[i]) ** (i + 1)
return total == num


if __name__ == "__main__":
import doctest

doctest.testmod(verbose=True)