Common Prime
Practice
3 (4 votes)
Algorithms
Easy
String manipulation
Problem
87% Success 16140 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}\)
Explanation
\(3\) is the smallest common prime factor of \(3\) and \(6\).
Code Editor
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
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
5 votes
Tags:
String AlgorithmsAlgorithmsString Searching
Points:20
3 votes
Tags:
String AlgorithmsReal worldAlgorithmsString Searching
3.Zeroes
Points:30
70 votes
Tags:
ReadyMathematicsMedium
Editorial
Login to unlock the editorial
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
Results
Custom Input
Run your code to see the output