The Prime Twins
Submissions: 555   Accuracy:


  Difficulty: Easy   Marks: 2

Given two positive numbers L and R (L < R), find out the smallest twins in the range [L , R].Two numbers are twins if they are prime numbers and there difference is 2.

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains two positve integers L and R (L < R), denoting the range [L < R].

Print out the smallest twins in the given range. If no such twins exist, then print -1.

1 <= T <= 200
0 <= L <= 500
0 <   R <= 1000

10 100
20 50
850 900
15 18

11 13
29 31
857 859


** For More Input/Output Examples Use 'Expected Output' option **

Author: Rohan Malhotra

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.