Skip to content

fix comment #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2020
Merged
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
10 changes: 6 additions & 4 deletions maths/armstrong_numbers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
An Armstrong number is a number that is equal to the sum of the cubes of its digits.
An Armstrong number is equal to the sum of the cubes of its digits.
For example, 370 is an Armstrong number because 3*3*3 + 7*7*7 + 0*0*0 = 370.
An Armstrong number is often called Narcissistic number.
"""


def armstrong_number(n: int) -> bool:
"""
This function checks if a number is Armstrong or not.
Return True if n is an Armstrong number or False if it is not.

>>> armstrong_number(153)
True
Expand Down Expand Up @@ -42,9 +42,11 @@ def armstrong_number(n: int) -> bool:
return n == sum


# In main function user inputs a number to find out if it's an Armstrong or not. Th function armstrong_number is called.
def main():
num = int(input("Enter an integer number to check if it is Armstrong or not: ").strip())
"""
Request that user input an integer and tell them if it is Armstrong number.
"""
num = int(input("Enter an integer to see if it is an Armstrong number: ").strip())
print(f"{num} is {'' if armstrong_number(num) else 'not '}an Armstrong number.")


Expand Down