Tuesday 13 September 2016

Maximum unique prime factor

Standard
Given q queries with each query containing a number n , your task is to find the maximum number of unique prime factor of a number in the range [1, n]

for example:-
if n=10
then in the range 1, 2,3,4,5,6,7,8,9,10
6 =2*3 and 10=2*5 has 2 unique prime factors, all other number have either 0 (1 in this case) or 1 ( 2,3,4,5,7,8,9) unique prime factors.
so your output will be.
2

if  n=1000
then in the range [1,1000]
the number 210 = 2*3*5*7 has 4 unique prime factors which is the maximum in the range [1,1000]
So your output will be
4

here is the input to your code.
11
100
210
999
1999
387456
12337857
1000000000
1222326389726
87562986844627
4269888900268907
98346736477364738

Submit your answers in the comment section.
You can use any of the following online compiler.


0 comments:

Post a Comment