Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5578 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3412 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 714 |

@Manikanta punnam | 587 |

@sriramgoparaju99 | 532 |

@praveenbgp6 | 525 |

@yashkaril4 | 517 |

@prankursharma31 | 489 |

@rdakka | 467 |

@sonamnigam1999 | 441 |

@sonamkumari63928 | 427 |

@purohitmn02 | 427 |

@shubhamstudent5 | 419 |

Complete Leaderboard |

Given two numbers **L** and **R** (inclusive) find the** product of primes **within this range. Print the product modulo **10 ^{9}+7**. If there are no primes in that range you must print 1.

**Example 1:**

**Input:** L = 1, R = 10
**Output:** 210
**Explaination:** The prime numbers are
2, 3, 5 and 7.

**Example 2:**

**Input:** L = 1, R = 20
**Output:** 9699690
**Explaination:** The primes are 2, 3,
5, 7, 11, 13, 17 and 19.

**Your Task:**

You do not need to read input or print anything. Your task is to complete the function **primeProduct()** which takes L and R and returns the product of the primes within the range. If there are no primes in that range then return 1.

**Expected Time Complexity:** O((R-L)*(logR))

**Expected Auxiliary Space:** O(sqrt(R))

**Constraints:**

1 ≤ L ≤ R ≤ 10^{9}

0 ≤ L - R ≤ 10^{6}

Login 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?

Yes
Product of Primes

...