0

Write a program to find greatest prime number in an given range

Language is either java or python

1st Nov 2019, 5:34 PM
Nirmala Agarwal
Nirmala Agarwal - avatar
3 Answers
+ 1
Hint: a prime number is only divisible by one and itself, there is no shortcut to avoid checking every division possible.
1st Nov 2019, 5:49 PM
Frenchtoast
Frenchtoast - avatar
+ 1
If range is from [a,b] (b>a), then start going from b to a, when find prime then break; from loop as it will be the largest prime in that range
2nd Nov 2019, 12:58 AM
Gaurav Agrawal
Gaurav Agrawal - avatar