{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eThe sequence of n − 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers \u003ci\u003ep\u003c/i\u003e and \u003ci\u003ep\u003c/i\u003e + \u003ci\u003en\u003c/i\u003e is called a prime gap of length \u003ci\u003en\u003c/i\u003e. For example, ‹24, 25, 26, 27, 28› between 23 and 29 is a prime gap of length 6.\u003c/p\u003e\u003cp\u003eYour mission is to write a program to calculate, for a given positive integer \u003ci\u003ek\u003c/i\u003e, the length of the prime gap that contains \u003ci\u003ek\u003c/i\u003e. For convenience, the length is considered 0 in case no prime gap contains \u003ci\u003ek\u003c/i\u003e.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input is a sequence of lines each of which contains a single positive integer. Each positive integer is greater than 1 and less than or equal to the 100000th prime number, which is 1299709. The end of the input is indicated by a line containing a single zero.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eThe 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 0 otherwise. No other characters should occur in the output.\u003c/p\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e10\r\n11\r\n27\r\n2\r\n492170\r\n0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n0\r\n6\r\n0\r\n114\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}