Primes are no longer popular. Semiprimes are now trendy, and everyone wants one.
A semiprime is a number which has two prime factors, which do not need to be distinct. For example, the square of a prime is a semiprime.
The first few semiprimes are , , , , , , , , , , .
You have friends you want to help out, numbered . Each friend has a number where .
For each friend, you are to find the smallest semiprime strictly greater than .
Constraints
Subtask | % of points | ||
---|---|---|---|
Input Specification
The first line will contain . The next lines will contain all .
Output Specification
The corresponding semiprime for each , one per line.
Sample Input
7
1
5
100
1000000000
100
123456
987654321
Sample Output
4
6
106
1000000006
106
123458
987654343
Explanation
Factor and see for yourself.
Comments
Is prime factorization the right approach to this question? Do I just need to further optimize my code or should I try something different?
I wish I had 50 thousand friends
I wish I had 1.
just do what I do and get some imaginary ones. then just multiply them by i and you'll have some friends :D
Wait doesn't that get you a negative amount of friends 😥
multiply by i two more times! problem solved 😎