Back
Close
  • 15

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

五 and 七 are two very young Japanese twin girls. They have an exceptional mental calculation ability, especially when it comes to prime numbers.
For a long time, they played a guessing game to determine whether a number was prime or not, but over time, it became too easy. 五 then suggested a new game: "Since we're twins, how about we find the next pair of prime twins?"
七, delighted, replied: "五, I even have an idea! We could make it our own secret language!"


Prime twins are pairs of prime numbers that differ by 2. For example, (11, 13) and (17, 19) are pairs of prime twins. Your task is to write a program that takes an integer 𝑛 as input and find the first pair of prime twins where both numbers are greater than 𝑛.
Input
an integer number 𝑛
Output
two integers separated by a space, for the first pair of prime twins both of which are greater than 𝑛
Constraints
1 ≤ 𝑛 ≤ 100,000
Example
Input
4
Output
5 7

A higher resolution is required to access the IDE