Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@SherlockHolmes3 | 447 |

@codeantik | 441 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

@neverevergiveup | 381 |

@amrutakashikar2 | 355 |

@mahlawatep | 353 |

@murarry3625 | 352 |

Complete Leaderboard |

Given two integers M and N, generate all primes between M and N.

**Example 1:**

**Input:**
M=1,N=10
**Output:**
2 3 5 7
**Explanation:**
The prime numbers between 1 and 10
are 2,3,5 and 7.

**Example 2:**

**Input:**
M=2, N=5
**Output:**
2,3,5
**Explanation:**
The prime numbers between 2 and 5 are
2,3 and 5.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function primeRange() which takes 2 integer inputs M and N and returns a list of all primes between M and N.

**Expected Time Complexity:**O(N*sqrt(N))

**Expected Auxillary Space:**O(1)

**Constraints:**

1<=M<=N<=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
Find Prime numbers in a range

...