DWITE Online Computer Programming Contest
March 2010
Problem 2
Round to Second Prime

More from the series of round to closest obscure function -- round to the closest second prime. That is, "round" an integer to a closest prime number such that there is exactly one other prime number between the original input and the result. If the input integer itself is a prime, it is still rounded (the requirement of having a prime in between). If there are two primes equally far away that both satisfy the condition, then the larger one is the answer.

The input file DATA2.txt will contain 5 lines, integers 5 <= N <= 100

The output file OUT2.txt will contain 5 lines, integer answers to corresponding lines of input.

Example: input is 7 (which incidentally is a prime). The two primes around it are 5 and 11. The two second primes around that are 3 and 13. 3 is closer to 7 than 13 is, so r(7) == 3

Sample Input:
5
6
7
8
9
		        
Sample Output:
2
3
3
5
13