N is a 6-digit positive integer whose sum of digits is 43.
Determine N, given that precisely one of the following statements is false:
- N is a perfect square
- N is a perfect cube
- N < 500000
The following Python program finds: 499849
as the sole solution
def sod(n):
""" Input an integer. Returns the Sum of the Digits """
aList = list(str(n))
ans = 0
for c in aList:
ans = ans + int(c)
return ans
for n in range(100000,1000000):
if sod(n) != 43:
continue
score = 0
if round(n**(1/2))**2 == n:
score += 1
if round(n**(1/3))**3 == n:
score += 1
if n < 500000:
score += 1
if score == 2:
print (n)
|
Posted by Larry
on 2020-07-06 07:12:55 |