Skip to content

Instantly share code, notes, and snippets.

@jakedobkin
Created December 16, 2011 19:13
Show Gist options
  • Select an option

  • Save jakedobkin/1487481 to your computer and use it in GitHub Desktop.

Select an option

Save jakedobkin/1487481 to your computer and use it in GitHub Desktop.
# http://projecteuler.net/problem=57
# python is well suited to doing this through simple brute force
max = 0
for a in range (1,100):
for b in range (1,100):
a2b = str(a**b)
sum = 0
for x in range (0,len(a2b)):
digit = int(a2b[x:x+1])
sum = sum + digit
if sum > max:
max = sum
print max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment