Math Is Fun
Time limit1sMemory limit1024 MB
Given n up to 1e9, find the smallest positive integer x such that x times Euler's totient of x equals n, or report that none exists.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Binary search, Brute force
- Solved
- No attempts yet
Problem
Euler loves math so much that he is a math nerd who studies math all day long.
One day, while reading a math book to study, Euler came across a passage explaining the Euler phi function. The Euler phi function was described as follows.
The Euler phi function is written and denotes the number of positive integers from 1 to that are coprime with .
For example, denotes the number of integers from 1 to 6 that are coprime with 6; since these are 1 and 5, two numbers in total, .
While reading the book carefully, Euler came up with a question. The question is as follows.
Given a positive integer , does there exist a positive integer satisfying ?
Seeing Euler lost in thought, you decided to solve the problem yourself to resolve his curiosity. Therefore, you need to write a program that finds satisfying .
Input
The first line gives . ()
Output
If a positive integer satisfying exists, print the smallest such ; otherwise, print .