I wrote this program for generating prime numbers between two values.
It's working perfectly for integer values.
I tried to make it work for long integer values but the program exits without any processing whenever long integer values are input.
Please help me find problem with the code
The code goes as follows.
public class Prime_generator
{
public static void main(String[] args) {
Scanner src = new Scanner(System.in);
Prime_generator obj = new Prime_generator();
int t, i, a;
t = src.nextInt();
if (t > 10)
System.exit(0);
long a1[] = new long[t];
long a2[] = new long[t];
for (i = 0; i < t; i++) {
a1[i] = src.nextLong();
a2[i] = src.nextLong();
}
for (a = 0; a < t; a++)
{
if (a1[a] >= 1 && a1[a] <= 1000000000 && a2[a] >= 1 && a2[a] <= 1000000000 && a2[a] - a1[a] <= 100000 && a1[a] <= a2[a])
obj.prime(a1[a], a2[a]);
else
System.exit(0);
}
}
void prime(long m, long n)
{
long j,k;
long c=0L;
for(j=m;j<=n;j++)
{
c=0L;
for(k=2;k<j/2;k++)
{
if((long)j%k==0L)
c++;
}
if(c==0L)
System.out.println(j);
}
System.out.println(" ");
}
}