Twin prime numbers are pairs of prime numbers that differ by 2. That is, and (with ) are twin primes if and are primes and . Except for the case of 2 and 3, this is the smallest difference that can exist between two primes. The first examples of the list of twin primes are the pairs , and .
The term was first used by the German mathematician Paul Stäckel who, at the end of the 19th century, made some numerical calculations related to these numbers and other related questions. It is not known if there are infinite twin prime numbers. The twin prime conjecture that states that, in fact, there are infinite twin primes, has not yet been proven[Wikipedia].
Write a program that, given a natural number , calculates the -th pair of twin primes. For example, if , the program must calculate the twin primes 11 and 13.
Your program should define and use the @nth_twin_primes(n: int) -> tuple[int, int]@ function, which returns the -pair of twin numbers for an . Your program should also define and use the @are_primes(m: int, n: int) -> bool@ function, which tells if and are primer numbers, for .
The input consist of a series of strictly positive integers .
For each you must write a line with the two twin primes that form the pair, separated by a space. Each pair must be in increasing order.
As many pairs of numbers will be composite, it is not a good idea to determine if both are prime separately in the @are_primes@ function.
Input
3 10 54 7 99
Output
11 13 107 109 1697 1699 59 61 3767 3769