Skip to content

Instantly share code, notes, and snippets.

@shieldsd
Created March 30, 2012 14:15
Show Gist options
  • Save shieldsd/2251803 to your computer and use it in GitHub Desktop.
Save shieldsd/2251803 to your computer and use it in GitHub Desktop.
Project Euler #28
def spiral(n):
max = n * n
s = 1
n = 1
i = 2
while n <= max:
for j in range(4):
if n >= max:
return s
else:
n += i
s += n
i = i + 2
return s
print spiral(1001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment