Skip to content

Instantly share code, notes, and snippets.

@tthtlc
Created June 28, 2021 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tthtlc/8c8795991bbed6673c0a7f45fb364065 to your computer and use it in GitHub Desktop.
Save tthtlc/8c8795991bbed6673c0a7f45fb364065 to your computer and use it in GitHub Desktop.
project euler problem 30
def sum_of_4th_power(a,b,c,d):
sum = a**4 + b**4 + c**4 + d**4
return sum
def sum_of_5th_power(a,b,c,d,e):
sum = a**5 + b**5 + c**5 + d**5 + e**5
return sum
sumsum = 0
for a in range(1,10):
for b in range(10):
sum = sum_of_5th_power(0,0,0,a,b)
if (sum == a*10+b):
print("two",a,b,sum)
sumsum += sum
for a in range(1,10):
for b in range(10):
for c in range(10):
sum = sum_of_5th_power(0,0,a,b,c)
if (sum == a*100+b*10+c):
print("three",a,b,c,sum)
sumsum += sum
for a in range(1,10):
for b in range(10):
for c in range(10):
for d in range(10):
sum = sum_of_5th_power(0,a,b,c,d)
if (sum == a*1000+b*100+c*10+d):
print("four",a,b,c,d,sum)
sumsum += sum
for a in range(1,10):
for b in range(10):
for c in range(10):
for d in range(10):
for e in range(10):
sum = sum_of_5th_power(a,b,c,d,e)
if (sum == a*10000+b*1000+c*100+d*10+e):
print("five",a,b,c,d,e,sum)
sumsum += sum
for a in range(1,10):
for b in range(10):
for c in range(10):
for d in range(10):
for e in range(10):
for f in range(10):
sum = sum_of_5th_power(a,b,c,d,e)+f**5
if (sum == a*100000+b*10000+c*1000+d*100+e*10+f):
print("six",a,b,c,d,e,f,sum)
sumsum += sum
print(sumsum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment