#C9854. Largest Prime Factor of Factorial

    ID: 53993 Type: Default 1000ms 256MiB

Largest Prime Factor of Factorial

Largest Prime Factor of Factorial

Given an integer (N), compute the largest prime factor of (N!) (where (N! = 1 \times 2 \times \cdots \times N)). Notice that since every prime (p \leq N) divides (N!), the largest prime factor of (N!) is simply the largest prime (p) such that (p \leq N). In the special case when (N = 1), since (1! = 1) has no prime factors, you should output "None".

You are given (T) test cases. For each test case, determine the largest prime that does not exceed (N) and print it on a separate line.

inputFormat

Input is read from standard input. The first line contains an integer (T), the number of test cases. Each of the following (T) lines contains a single integer (N).

outputFormat

For each test case, output the largest prime factor of (N!) (i.e. the largest prime (\leq N)) on a separate line. If (N < 2), output "None".## sample

3
6
10
15
5

7 13

</p>