#C7463. Good Numbers in Prime Pairs
Good Numbers in Prime Pairs
Good Numbers in Prime Pairs
You are given several sequences of integers. A number is called good if it is part of at least one pair of consecutive prime numbers within its sequence. Your task is to count the number of distinct good numbers for each sequence.
Each test case consists of a single line containing a sequence of space-separated integers. Input is terminated by a line containing a single zero. For each sequence (except the termination line), output the count of good numbers on a separate line.
Note: A prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself. All formulas should be rendered in LaTeX. For example, the condition for a prime number can be expressed as \(n>1\) and \(\forall k\ (2 \le k \le \sqrt{n}: k \nmid n)\).
inputFormat
The input consists of multiple lines. Each line (except the last) contains a sequence of space-separated integers. A line containing a single 0
indicates the end of input. You should process all lines before the termination line.
Input is read from stdin.
outputFormat
For each sequence, output a single integer on a new line: the count of distinct good numbers. Output is written to stdout.
## sample2 3 5 7 11 13
4 6 9 15 17 19
23 29 31 37 41 43 47
0
6
2
7
</p>