Given an integer n, find the nth Fortunate Number.
A Fortunate number is the smallest integer m > 1 such that, for a given positive integer n, pn + m is a prime number. Here pn is the product of the first n prime numbers, i.e prime factorials (or primorials) of order n.
The first line contains an integer T, number of test cases. For each test case, there is an integer n.
For each test case, the output is an integer m displaying the nth Fortunate Number.
1. 7 must be added to the product of first n prime numbers to make the product prime. 2 x 3 x 5 = 30, need to add 7 to make it 37, which is a prime.
2. 23 must be added to the product of first n prime numbers to make the product prime. 2 x 3 x 5 x 7 x 11= 2310, need to add 23 to make it 2333, which is a prime.
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.