The Lucky Letter
Time limit2sMemory limit512 MB
Find the smallest positive n whose remainder modulo every a from 2 to m equals a-1, that is, n ≡ -1 mod each a.
- Level
Medium4 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
Jigui got this letter one day.
This letter began in England, travelled around the world once a year, and brought luck to everyone who received it. Now it has reached you. You must solve the problem below within 12 hours and send seven copies of this letter, this one included, to people who need luck. Copying is allowed. (...) The number written on this letter is . Find the smallest positive integer such that for every natural number with .
Jigui read the letter all the way to the end by accident and has felt uneasy ever since, because the problem is still unsolved. Solve it for Jigui.
Put another way, find the smallest positive integer whose remainder on division by equals for every integer with .
Input
The first line contains the integer written on the letter. ()
Output
Print the smallest positive integer that satisfies the condition. When is , has digits, so it does not fit in a 64-bit integer type.