Maximum number of unique prime factors in python

Leonardo loves primes and created q queries where each query takes the form of an integer, n . For each n , he wants you to count the maximum number of unique prime factors of any number in the inclusive range [1,n] and then print this value on a new line.

Note: Recall that a prime number is only divisible by 1

and itself, and 1 is not a prime number.

Input Format

The first line contains an integer,q , denoting the number of queries.
Each i line of the q subsequent lines contains a single integer, n .

Output Format

For each query, print the maximum number of unique prime factors for any number in the inclusive range [1,n] on a new line.

Sample Input


Sample Output


This problem from hackerrank.

Here what is Maximum number of unique prime factors? What They really want,i read this problem for couple time but confused :frowning:

Note: i don’t want the solution of this problem,i just want to clear unique prime factor concept.

It’s literally what the name says. Number of unique primes, which are factors of certain number. For example 8:
8 = 2 * 2 * 2
36 = 2 * 2 * 3 * 3
So 8 has just 1 unique prime factor and 36 has 2 unique prime factors.

It might be helpful if you’d try to write on your own how you understand this or what exactly is confusing you.


Thank you so much sanity :smiling_face_with_three_hearts:

This is a terribly written question.

They want you to know how many unique prime factors it takes for the product of these prime factors to exceed the upper bound given.

For example, with 500, 2*3*5*7 = 210 and 2*3*5*7*11 = 2310, so there can be at most 4 unique prime factors for numbers between 1 and 500.

1 Like

I’m sorry for my question written style :frowning:
Thank you for you reply it helps me a lot :sparkling_heart:

I meant that the question from hackerrank, not from you : )

1 Like

Oh, pleasure :hushed::heart_eyes: :smiling_face_with_three_hearts:

1 Like