Primorial of a number
Easy Accuracy: 12.49% Submissions: 16 Points: 2

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#.


Example 1:

N = 5
Output: 30
Priomorial = 2 * 3 * 5 = 30
As a side note, factorial is 2 * 3 * 4 * 5


Example 2:

N = 12
Output: 2310

Your Task:  
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

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Primorial of a number

Output Window