-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumfact.py
More file actions
33 lines (29 loc) · 741 Bytes
/
numfact.py
File metadata and controls
33 lines (29 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from functools import reduce
from math import sqrt
count = {}
def getNumFactors(num):
f = 2
while f*f <= num:
while num%f==0:
num = num // f;
if f in count:
count[f]+=1
else:
count[f]=1
if f > 2:
f+=2 #incrementing by 2 because after 2 all prime numbers are odd
else:
f+=1
if num != 1:
if num not in count:
count[num] = 0
count[num] += 1
T = int(input())
for i in range(T):
count.clear()
n = int(input())
l = list(map(int,input().split()))
for j in l:
getNumFactors(j)
#print (count)
print(reduce(lambda a,b: a*b, map(lambda a:a+1,count.values())))