For some reason, this code keeps giving me wrong answers, which I went through and got the right prime numbers up to 200.
import java.io.*;
import java.util.Scanner;
public class Main
{
private static int from;
private static int to;
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int times = sc.nextInt();
for (int i = 0; i < times && times > 0; i++)
{
from = sc.nextInt();
to = sc.nextInt();
while (from < to)
{
if (from==2 || from==3 || from==5 || from==7 && from!=1)
System.out.println(from);
if (from%2!=0 && from%3!=0 && from%5!=0 && from%7!=0 && from!=1)
System.out.println(from);
from++;
}
}
}
}