#K4396. Counting Twin Primes

    ID: 27425 Type: Default 1000ms 256MiB

Counting Twin Primes

Counting Twin Primes

Your task is to count the number of twin prime pairs within a given range. Two prime numbers \(p\) and \(p+2\) form a twin prime pair if both are prime and \(p+2 \leq n\).

For instance, when \(n = 10\), the twin prime pairs are \((3, 5)\) and \((5, 7)\), so the answer is 2.

You must read the input from standard input (stdin) and print the output to standard output (stdout).

inputFormat

The input consists of a single integer (n) (with (n \geq 1)) which represents the upper bound within which you must search for prime numbers.

outputFormat

Output a single integer which is the number of twin prime pairs where both primes are less than or equal to (n).## sample

10
2

</p>