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

Function sum_of_divisors

project_euler/problem_021/sol1.py:20–27  ·  view source on GitHub ↗
(n: int)

Source from the content-addressed store, hash-verified

18
19
20def sum_of_divisors(n: int) -> int:
21 total = 0
22 for i in range(1, int(sqrt(n) + 1)):
23 if n % i == 0 and i != sqrt(n):
24 total += i + n // i
25 elif i == sqrt(n):
26 total += i
27 return total - n
28
29
30def solution(n: int = 10000) -> int:

Callers 1

solutionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected