MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / diagonal_sum

Function diagonal_sum

project_euler/problem_28/sol1.py:9–17  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

7 xrange = range #Python 3
8
9def diagonal_sum(n):
10 total = 1
11
12 for i in xrange(1, int(ceil(n/2.0))):
13 odd = 2*i+1
14 even = 2*i
15 total = total + 4*odd**2 - 6*even
16
17 return total
18
19if __name__ == '__main__':
20 import sys

Callers 1

sol1.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected