Skip to content
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

Problems #92

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Problems #92

wants to merge 3 commits into from

Conversation

VittalKumar23
Copy link

def is_armstrong_number(number):
# Convert the number to a string to count its digits
num_str = str(number)
n = len(num_str)

# Calculate the sum of each digit raised to the nth power
digit_sum = sum(int(digit) ** n for digit in num_str)

# Check if the sum is equal to the original number
return digit_sum == number

Example usage

number = 153
if is_armstrong_number(number):
print(f"{number} is an Armstrong number.")
else:
print(f"{number} is not an Armstrong number.")

@VittalKumar23 VittalKumar23 changed the title Create armstrong.py Problems Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant