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

Function sumOfDivisors

maths/basic_maths.py:37–55  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

35 return div
36
37def sumOfDivisors(n):
38 s = 1
39
40 temp = 1
41 while n % 2 == 0:
42 temp += 1
43 n = int(n / 2)
44 if temp > 1:
45 s *= (2**temp - 1) / (2 - 1)
46
47 for i in range(3, int(math.sqrt(n))+1, 2):
48 temp = 1
49 while n % i == 0:
50 temp += 1
51 n = int(n / i)
52 if temp > 1:
53 s *= (i**temp - 1) / (i - 1)
54
55 return s
56
57def eulerPhi(n):
58 l = primeFactors(n)

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected