• 沒有找到結果。

Your mission is to write a program to calculate, for a given positive integer k, the length of the prime gap that contains k

N/A
N/A
Protected

Academic year: 2021

Share "Your mission is to write a program to calculate, for a given positive integer k, the length of the prime gap that contains k"

Copied!
1
0
0

加載中.... (立即查看全文)

全文

(1)

1644 Prime Gap

The sequence of n− 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and p + n is called a prime gap of length n.

For example,⟨24, 25, 26, 27, 28⟩ between 23 and 29 is a prime gap of length 6.

Your mission is to write a program to calculate, for a given positive integer k, the length of the prime gap that contains k. For convenience, the length is considered 0 in case no prime gap contains k.

Input

The 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.

Output

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 ‘0’ otherwise. No other characters should occur in the output.

Sample Input

10 11 27 2 492170 0

Sample Output

4 0 6 0 114

參考文獻

相關文件

 Having found that the fines as a whole are a measure falling within the scope of Article XI:1 and contrary to that provision, the Panel need not examine the European

More precisely, it is the problem of partitioning a positive integer m into n positive integers such that any of the numbers is less than the sum of the remaining n − 1

The purpose of this research is to study a tiling problem: Given an m × n chessboard, how many ways are there to tile the chessboard with 1 × 2 dominoes and also ”diagonal”

The existence and the uniqueness of the same ratio points for given n and k.. The properties about geometric measurement for given n

Then, it is easy to see that there are 9 problems for which the iterative numbers of the algorithm using ψ α,θ,p in the case of θ = 1 and p = 3 are less than the one of the

A subgroup N which is open in the norm topology by Theorem 3.1.3 is a group of norms N L/K L ∗ of a finite abelian extension L/K.. Then N is open in the norm topology if and only if

n SCTP ensures that messages are delivered to the SCTP user in sequence within a given stream. n SCTP provides a mechanism for bypassing the sequenced

It is useful to augment the description of devices and services with annotations that are not captured in the UPnP Template Language. To a lesser extent, there is value in