题目描述
Given an integer n, find the n'th 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.
Example 1:
Input:
n = 3
Output:
7
Explanation:
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.
Example 2:
Input:
n = 5
Output:
23
Explanation:
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.
Your Task:
You don't need to read input or print anything. Your task is to complete the function nthFortunateNum() which takes an Integer n as input and returns the n'th Fortunate Number.
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)
Constraints:
1 <= n <= 15
输入格式
见题面
输出格式
见题面