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

Function count_divisors

project_euler/problem_012/sol2.py:31–43  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

29
30
31def count_divisors(n):
32 divisors_count = 1
33 i = 2
34 while i * i <= n:
35 multiplicity = 0
36 while n % i == 0:
37 n //= i
38 multiplicity += 1
39 divisors_count *= multiplicity + 1
40 i += 1
41 if n > 1:
42 divisors_count *= 2
43 return divisors_count
44
45
46def solution():

Callers 1

solutionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected