Skip to content

Problems #92

New issue

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

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

Already on GitHub? # to your account

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant