MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_120/sol1.py:18–28  ·  view source on GitHub ↗

Returns ∑ r_max for 3 <= a <= n as explained above >>> solution(10) 300 >>> solution(100) 330750 >>> solution(1000) 333082500

(n: int = 1000)

Source from the content-addressed store, hash-verified

16
17
18def solution(n: int = 1000) -> int:
19 """
20 Returns ∑ r_max for 3 <= a <= n as explained above
21 >>> solution(10)
22 300
23 >>> solution(100)
24 330750
25 >>> solution(1000)
26 333082500
27 """
28 return sum(2 * a * ((a - 1) // 2) for a in range(3, n + 1))
29
30
31if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected