Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class PrimeNum {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int a = input.nextInt();
- int b = input.nextInt();
- for(int i = a ; i <= b ; i++ ) {
- if ( i == 2 || i == 3 ) System.out.println(i);
- int root = (int) Math.sqrt(i);
- for(int j = 2; j <= root ; j++ ) {
- if ( (i % j) == 0 ) break;
- if ( j == root ) System.out.println(i);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment