#K34382. Smallest Prime Divisor
Smallest Prime Divisor
Smallest Prime Divisor
Given an integer \(n\), find its smallest prime divisor. If \(n\) is composite, the answer is the smallest prime number that divides \(n\). If \(n\) is a prime number, then its smallest prime divisor is \(n\) itself. For \(n \le 1\), output None
.
For example, for \(n = 15\) the smallest prime divisor is \(3\) since \(3\) divides \(15\) and is prime. Similarly, for \(n = 7\), the answer is \(7\).
inputFormat
The input begins with an integer \(T\) denoting the number of test cases. Each of the following \(T\) lines contains a single integer \(n\).
outputFormat
For each test case, output a single line containing the smallest prime divisor of \(n\). If \(n \le 1\), output None
.
3
15
2
77
3
2
7
</p>