Common Prime
Practice
3 (4 votes)
Algorithms
Easy
String manipulation
Problem
87% Success 16134 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given two numbers \(A\) and \(B\), find the smallest prime number that divides both of them or state that such number does not exist.

Input

First and only line of input contains two integers \(A\) and \(B\).

Output

Print the smallest common prime divisor of \(A\) and \(B\) or \(-1\) if it does not exist.

Constraints

\(1 \le A,B \le 10^{15}\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
7 votes
Tags:
ApprovedEasyGraphsReady
Points:20
5 votes
Tags:
String AlgorithmsAlgorithmsString Searching
Points:20
15 votes
Tags:
AlgorithmsString ManipulationString manipulation