Finished
11def is_armstrong_number(number):
2 pass
2 # Edge Case: Negative numbers are not considered Armstrong numbers
3 if number < 0:
4 return False
5
6 # Convert number to string to easily access individual digits
7 num_str = str(number)
8 num_digits = len(num_str)
9
10 # Edge Case: Single digit numbers are always Armstrong numbers
11 if num_digits == 1:
12 return True
13
14 # Calculate sum of each digit raised to the power of number of digits
15 total = sum(int(digit) ** num_digits for digit in num_str)
16
17 # Check if the total equals the original number
18 return total == number
19
20# Handled Edge Cases: Negative numbers, Single digit numbers
Test NameStatus
test_four_digit_number_that_is_an_armstrong_number
Pass
test_four_digit_number_that_is_not_an_armstrong_number
Pass
test_seven_digit_number_that_is_an_armstrong_number
Pass
test_seven_digit_number_that_is_not_an_armstrong_number
Pass
test_single_digit_numbers_are_armstrong_numbers
Pass
test_there_are_no_two_digit_armstrong_numbers
Pass
test_three_digit_number_that_is_an_armstrong_number
Pass
test_three_digit_number_that_is_not_an_armstrong_number
Pass
test_zero_is_an_armstrong_number
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.