Sexy Primes
Submissions: 2329   Accuracy:

11.16%

  Difficulty: Easy   Marks: 2

Sexy primes are prime numbers that differ from each other by six. For example, the numbers 5 and 11 are both sexy primes, because they differ by 6. Given a range of the form [L, R]. The task is to print all the sexy prime pairs in the range in increasing order.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case two integers L and R.

Output:
For each test case, print all the sexy prime pairs in the range in increasing order in new line. If no sexy prime pair is there print "-1".

Constraints:
1<=T<=100
1<=L<=R<=107

Example:
Input:

2
11 19
6 59
Output:

11 17 13 19
7 13 11 17 13 19 17 23 23 29 31 37 37 43 41 47 47 53 53 59

Explanation:

Input : L = 6, R = 59
Output : (7, 13) (11, 17) (13, 19) 
(17, 23) (23, 29) (31, 37) (37, 43) 
(41, 47) (47, 53) (53, 59)

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

Author: arun03


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 ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.