write a program in java to print 50 simultaneous prime number between m and n when m is less than n
Answers
Answered by
1
Answer:
Explanation:
public class Prime {
public static void main(String[] args) {
int low = 20, high = 50;
while (low < high) {
boolean flag = false;
for(int i = 2; i <= low/2; ++i) {
// condition for nonprime number
if(low % i == 0) {
flag = true;
break;
}
}
if (!flag)
System.out.print(low + " ");
++low;
}
}
}
aayushiverma:
thanks for the answer......
Similar questions