O Fortuna
Time limit1sMemory limit1024 MB
Given N, compute P as the product of the first N primes, then output Q minus P (Q is the next prime above P+1) and P minus Q (Q is the previous prime below P-1).
- Level
Medium4 of 10
- Topics
- Number theory, Implementation
- Solved
- No attempts yet
Problem
Some numbers in mathematics are fortunate, and others are less fortunate. A fortunate number is , where is the product of the first prime numbers (), and is the smallest prime greater than . For example, with , . The smallest prime greater than 7 is 11, so the fortunate number is , which is also prime. Some mathematicians have conjectured that fortunate numbers are always prime.
A less fortunate number is , using the same , except that is the largest prime less than . With , , so (the largest prime less than 5), and the less fortunate number is . A similar conjecture says that less fortunate numbers are always prime.
Input
A single integer with .
Output
Print the input value , followed by the fortunate number and the less fortunate number as described above. Separate each output item with a single space.