题面
The sequence of consecutive composite numbers (positive integers that are not prime and not equal to ) lying between two successive prime numbers and is called a prime gap of length . For example, between and is a prime gap of length .
Your mission is to write a program to calculate, for a given positive integer , the length of the prime gap that contains . For convenience, the length is considered in case no prime gap contains .
输入格式
The input is a sequence of lines each of which contains a single positive integer. Each positive integer is greater than and less than or equal to the -th prime number, which is . The end of the input is indicated by a line containing a single zero.
输出格式
The output should be composed of lines each of which contains a single non-negative integer. It is the length of the prime gap that contains the corresponding positive integer in the input if it is a composite number, or otherwise. No other characters should occur in the output.
样例
输入
10 11 27 2 492170 0
输出
4 0 6 0 114