Last active
August 29, 2015 14:11
-
-
Save ebartrum/5405cc5fa0aad66c5818 to your computer and use it in GitHub Desktop.
A solution to the 28th Project Euler problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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