The 3 integers I have in mind sum up to 35 and their product is 720.
Please find them.
You have a selection:
(3,12,20) sum=35 prod=720
(5,6,24) sum=35 prod=720
(45,-2,-8) sum=35 prod=720
-------
def divisors(n):
""" output a list of all factors of n including 1 and n """
ans = []
for i in range(1,n+1):
if n%i == 0:
ans.append(i)
ans = ans + [-i for i in ans]
return ans
facs = divisors(720)
solutions = []
for f in facs:
a = divisors(int(720/f))
for d in a:
e = int(720/(f*d))
if f+d+e == 35:
solution = sorted([f,d,e])
if solution in solutions:
continue
solutions.append(solution)
print( '({},{},{}) sum={} prod={}'.format(f,d,e,f+d+e, f*d*e))
|
Posted by Larry
on 2023-02-27 08:34:23 |