Each of a, b, and c is a different base ten digit and n is a positive integer such that:
ab2+c2=ac2+cb2=n
For example:
272+12=212+172=730
Determine the total number of values of the positive integer constant n less than 2023, such that we will have valid values of a,b, and c satisfying the abovementioned condition.
***** No number can contain any leading zero.
Program finds only 3 solutions:
a b c n
2 7 1 730
3 4 1 1157
4 3 1 1850
----------------
def f(a,b,c):
return (10*a+b)**2 + c**2
def g(a,b,c):
return (10*a+c)**2 + (10*c+b)**2
ansList = []
for a in range(0,10):
for b in range(0,10):
if a == b:
continue
for c in range(0,10):
if a == c or b == c:
continue
gg = g(a,b,c)
if gg > 2023:
continue
ff = f(a,b,c)
if ff > 2023:
continue
if ff == gg:
if ff not in ansList and ff < 2024:
ansList.append(ff)
print(a,b,c,ff)
continue
print(len(ansList))
|
Posted by Larry
on 2023-04-22 06:40:44 |