An Armstrong number is a positive integer that equals the sum of M-th powers of their digits when the number is M-digit long.
153 is an Armstrong number, since: 1
3+5
3+3
3=153.
Sloane's A005188 has an article on this, in which inter-alia it is mentioned that the sequence of Armstrong numbers terminates at the 88th term.
An
Armstwo number is a base ten, M-digit long positive integer which is equal to the sum of M-th powers of
one greater than each of the digits.
For example, if we check for 153, we find that:
2
3+6
3+4
3= 288, which is NOT equal to 153.
Determine the smallest Armstwo number.
**** Heartfelt thanks to Larry for inspiring this puzzle.
A sincere "you're welcome" and many thanks to K Sengupta for inspirational credit.
I tested integers up to 10^7 and only found three solutions, the smallest being 141.
{141, 251, 560} is the set of solutions I found.
here is my Python code (I included a function to test for Armstrong numbers as a warm-up to testing for Armstwo numbers)
--------------
def isArmstrong(n):
digits = list(str(n))
power = len(digits)
ans = 0
for d in digits:
ans += int(d)**power
return ans == n
def isArmstwo(n):
digits = list(str(n))
power = len(digits)
ans = 0
for d in digits:
ans += (int(d)+1)**power
return ans == n
big = 10000000
count = 0
for i in range(big):
if isArmstwo(i):
print(i, 'is an Armstwo number')
count += 1
print(count)
--------------
Output:
141 is an Armstwo number
251 is an Armstwo number
560 is an Armstwo number
3
|
Posted by Larry
on 2021-12-27 10:35:31 |