Solution to Problem 28

This commit is contained in:
Daniel Ingram 2018-03-14 17:18:59 -04:00
parent 7704151504
commit 81dc221ee2

View File

@ -1,11 +1,12 @@
from __future__ import print_function
from math import ceil
def diagonal_sum(n):
total = 1
for i in xrange(n/2):
odd = 2*(i+1)+1
even = 2*(i+1)
for i in xrange(1, int(ceil(n/2.0))):
odd = 2*i+1
even = 2*i
total = total + 4*odd**2 - 6*even
return total