14 lines
301 B
Python
14 lines
301 B
Python
def prime_factors(n: int) -> list:
|
|
factors = []
|
|
d = 2
|
|
while d * d <= n:
|
|
while n % d == 0:
|
|
factors.append(d)
|
|
n //= d
|
|
d += 1 if d == 2 else 2
|
|
if n > 1:
|
|
factors.append(n)
|
|
return factors
|
|
|
|
print(prime_factors(12))
|
|
print(prime_factors(77)) |