An Armstrong Number is an N-digit number that is equal to the sum of the Nth powers of its digits.
An example is all single digit numbers. Take 5
for example. 5
is a single digit and 5^1
is equal to 5
, therefore it is an Armstrong number.
5 = 5^1
5 = 5
Another example is 371
. 371
is three digits. 3^3 + 7^3 + 1^3
is 27 + 343 + 1
, which added together is 371
. Thus 371
is an Armstrong number.
371 = 3^3 + 7^3 + 1^3
371 = 27 + 343 + 1
371 = 371
Write a program in Python and Javascript to find all Armstrong numbers in the range of 0
and 999
.
Don't forget to run the tests!
Review your code, How can you make this more scalable and reusable later?
- Can you think of any more tests for your program?