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

Function primeFactors

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

Source from the content-addressed store, hash-verified

1import math
2
3def primeFactors(n):
4 pf = []
5 while n % 2 == 0:
6 pf.append(2)
7 n = int(n / 2)
8
9 for i in range(3, int(math.sqrt(n))+1, 2):
10 while n % i == 0:
11 pf.append(i)
12 n = int(n / i)
13
14 if n > 2:
15 pf.append(n)
16
17 return pf
18
19def numberOfDivisors(n):
20 div = 1

Callers 2

eulerPhiFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected