Write a program to print all sophie germain number less than n. A prime number **p** is called a *sophie** prime number* if **2p+1** is also a prime number. The number **2p+1** is called a *safe prime*. For example **11** is a prime number and 11*2 + 1 = 23 is also a prime number so, 11 is sophie germain prime number .

**Input:**

The first line of the input contains a single integer **T**, denoting the number of test cases. Then **T** test case follows, a single line of the input containing a positive integer N.

**Output: **

For each testcase, print all sophie germain number less than n.

**Constraints:**

1<=T<=100

3<=10000<=N

**Example:
Input:**

1

25

**Output:**

2 3 5 11 23

Explanation**: **For p =2 , 2p+1 = 5 which is also a prime. Similarly for 3 = 7, for 5 = 11, for 11 = 23, for 23 = 47 all are primes. So for every mentioned primes, 2p+1 is also prime which satisfies sophie germain prime number condition.

Author: Sahil_Chhabra

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.

VISHESHA SADU | 27 |

ghanshyam648 | 25 |

Biswajit3 | 21 |

karthik_kasaragadda | 20 |

tanya_sharma | 18 |

KshatriyaYash | 1066 |

nikhil_sojan | 978 |

lonecoder | 935 |

mazumderrohit8 | 864 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4468 |

Quandray | 4444 |

Login to report an issue on this page.