Project Euler Problem 28
これは、図を見てえいやっと考えれば簡単。
#!/usr/bin/python EDGE_MAX = 1001 a,b,c,d = 3,5,7,9 s = 1 diff = 10 while b-a+1 <= EDGE_MAX: s += a + b + c + d edge = b - a + 2 a += diff diff += 8 b = a + edge c = b + edge d = c + edge print s
これは、図を見てえいやっと考えれば簡単。
#!/usr/bin/python EDGE_MAX = 1001 a,b,c,d = 3,5,7,9 s = 1 diff = 10 while b-a+1 <= EDGE_MAX: s += a + b + c + d edge = b - a + 2 a += diff diff += 8 b = a + edge c = b + edge d = c + edge print s