Relatively Prime Pairs
You are given a set of all integers from l to r inclusive (r - l is odd).You want to split these numbers into exactly (r-l+1)/2 pairs in such a way that for each pair (i,j), the greates common divisor of i and j is equal to 1.Input Format
Each pair should appear in exactly one of the pairs.
Print the resulting pairs or output that no solution exists.
The only line contains two integer l and r.Output Format
If any solution exists, print "YES" in the first line. Each of next (r-l+1)/2 line contains some pair of integers. GCD of each pair of integers should be equal to 1.Question Video
If there exists no solution print "NO".
1 <= l, r, <= 10^8Sample Input
r-l+1 <= 10^5 and r-l is odd
1 8Sample Output
YES
1 2
3 4
5 6
7 8
-
Asked in Companies
-
Related Topics
Video Solution
Code Solution
{ }
{ }
Run