Print Prime Numbers in the given range
import java.util.*;
public class practice {
public static void prime(int a,int b){
for(int i=a;i<b;i++){
for(int j=2;j<i;j++){
if(i%j==0){
break;
}
else{
System.out.println(i);
break;
}
}
}
}
public static void main(String[] args) {
Scanner s =new Scanner(System.in);
int a,b;
System.out.println("Enter the number range");
a=s.nextInt();
b=s.nextInt();
prime(a,b);
}
}
Comments
Post a Comment