What Makes 2021 Special?
InterviewTime limit1sMemory limit1024 MB
Given N, find the smallest number greater than N that is the product of two consecutive primes, such as 43 × 47 = 2021.
- Level
Easy2 of 10
- Topics
- Math, Brute force
- Solved
- No attempts yet
Problem
The year-end contest Good Bye 2021! on an online judge is held on December 31, 2021. Wonyi was so happy about the contest that he stared at the title, and then he noticed that 2021 is special in some way.
Yes. 2021 is the product of 43 and 47, two consecutive primes. The next year of this kind is 2491, which is 470 years later. Wonyi calls a number special when it is the product of two consecutive primes.
Write a program that finds the smallest special number greater than the given number.
Input
The first line contains the given number .
Output
Print the smallest special number greater than on the first line.
Constraints
- is an integer.
Hints
- A prime is an integer greater than or equal to 2 that is divisible only by 1 and itself.
- Primes and are consecutive when and are prime, , and no prime lies strictly between and .