Skip to content

Instantly share code, notes, and snippets.

@ebartrum
Last active August 29, 2015 14:11
Show Gist options
  • Save ebartrum/5405cc5fa0aad66c5818 to your computer and use it in GitHub Desktop.
Save ebartrum/5405cc5fa0aad66c5818 to your computer and use it in GitHub Desktop.
A solution to the 28th Project Euler problem
ans=1
n=1001
y=range(3,n+1,2)
#The solution comes from the observation that the sum of 4 nxn corner squares is the following poly (for odd n>1)
def poly(x):
ans=4*x**2-6*x+6
return ans
for o in y:
ans+=poly(o)
print ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment