Given a number n, the task is to calculate its primorial. Primorial of a number is similar to factorial of a number. In primorial, not all the natural numbers get multiplied; only prime numbers are multiplied to calculate the primorial of a number. It is denoted with P#.
Input: N = 5 Output: 30 Explanation: Priomorial = 2 * 3 * 5 = 30 As a side note, factorial is 2 * 3 * 4 * 5
Input: N = 12 Output: 2310
You don't need to read input or print anything. Your task is to complete the function primorial() which takes the integer N as input parameters and returns the primorial of number n. Since the answer can be quite large print it modulo 109+7.
Expected Time Complexity: O(N*sqrt(N))
Expected Auxiliary Space: O(1)
1 ≤ N ≤ 105
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes