Thanks sir, Excellent Explanations but it does not work for 0,1 or any negative numbers! How can it may solved?
@AjayKumar-sg7dd2 жыл бұрын
0 and 1 are not prime numbers.
@kyawkyawaung2362 Жыл бұрын
Firstly, thanks a lot for this excellent explanation!. based on this tutorials, I solved in this way to exclude 0,1 and negative minimum input for my exam and output for primeCount. See the code for your info. public class PrimeNumberBtwStartAndEnd { public static void main(String[] args) { primeCount(10, 30); primeCount(11, 29); primeCount(20, 22); primeCount(1, 1); primeCount(5, 5); primeCount(6, 2); primeCount(-10, 6); } public static void primeCount(int start, int end) { int count = 0, flag = 0; for (int n = start; n
@MrW4gyu Жыл бұрын
Math.abs
@sulaimandanish4561 Жыл бұрын
will it work for 2?@@AjayKumar-sg7dd
@gurushinde9694 Жыл бұрын
you can add an if block within the first for loop to check for 0 and 1
@skv2920026 ай бұрын
How to find range between nth prime number positions