MMFLPDIV - Least prime divisor


Given odd integer n > 2 compute its least prime divisor.

Input

Each line of input contains one random odd integer number 2 < n < 108 (100 000 000). Input terminates with 0 (zero). There will be two input files.

Output

For each n print its least prime divisor on new line.

Example

Input:
3
9
11
15
49
0
Output:
3
3
11
3
7

hide comments
nadstratosfer: 2018-06-12 06:09:14

Bruteforce outperforms sieve in C by a large margin. Perhaps updating testcases so that they're heavy in large primes could change this?


Added by:julkas
Date:2018-06-10
Time limit:60s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All