A List Game
This commit is contained in:
19
listgame.py
Normal file
19
listgame.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
|
||||
x = int(sys.stdin.readline())
|
||||
|
||||
def prime_factors(n):
|
||||
"""Returns all the prime factors of a positive integer"""
|
||||
factors = []
|
||||
d = 2
|
||||
while n > 1:
|
||||
while n % d == 0:
|
||||
factors.append(d)
|
||||
n /= d
|
||||
d = d + 1
|
||||
if d*d > n:
|
||||
if n > 1: factors.append(n)
|
||||
break
|
||||
return factors
|
||||
|
||||
print(len(prime_factors(x)))
|
||||
Reference in New Issue
Block a user