Mersenne Prime
Submissions: 322   Accuracy:

40.69%

  Difficulty: Easy   Marks: 2

Mersenne Prime is a prime number that is one less than a power of two. In other words, any prime is Mersenne Prime if it is of the form 2k-1 where k is an integer greater than or equal to 2. First few Mersenne Primes are 3, 7, 31 and 127.

The task is print all Mersenne Primes smaller than an input positive integer n.

Input:

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 the integer N.

Output:

Print all the mersenne primes smaller than n in a sorted order. Print a space between two numbers.


Constraints:

1<= T <=100

1<= N <=100000


Example:

Input:

2

10

100

Output:

3 7

3 7 31

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

Contributor: Sujnesh Mishra
Author: sujnesh


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.