Tuesday 13 September 2016

Unique prime factors

Standard
You are given q queries with each query containing  a number n , your task is to find and print it's total number of unique prime factor .
for example:-
if n=100
Now 100= 2*2*5*5
so number of unique prime factors of 100 is 2 (i.e. 2 and 5).
so your output will look like
100 has 2 unique prime factors : 2 5 

if n=420
210=2*2*3*5*7
here number of unique prime factor would be 4 (i.e. 2, 3, 5, 7)
Here your output will be
210 has 4 unique prime factors : 2 3 5 7

First try to come up with the solution for the above 2 cases. If succeeded than try with these inputs.
Note: Here the first one(i.e. 10 ) denotes the number of test cases.
10
100
210
999
1999
387456
12337857
1000000000
1222326389726
87562986844627
4269888900268907

98346736477364738

Post your answers in the comment section.
You can use any of the compiler listed below to test your code
codepad
online compiler







0 comments:

Post a Comment