Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static boolean isPrime(int n) {
- if (n ==1 )
- return false;
- for(int i=2;i < n;i++) {
- if(n%i==0)
- return false;
- }
- return true;
- }
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int cases = input.nextInt();
- int counter;
- int n;
- int m;
- for (int i = 0; i < cases; i++) {
- counter = 0;
- n = input.nextInt();
- m = input.nextInt();
- for (int j = n; j < m; j++) {
- if (isPrime(j))
- counter++;
- }
- System.out.println(counter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement