import java.util.*;
public class PrimeGenerator {
static Scanner sc = new Scanner(System.in);
public static void main(String[]args){
byte testCases = sc.nextByte();
int inputToArray =0;
long [] numbers = new long[2*testCases];
while(inputToArray < numbers.length){
numbers[inputToArray] = sc.nextLong();
inputToArray++ ;
}
int arrayCounter = 0;
while(testCases>0){
long minBorder = numbers[arrayCounter++];
long maxBorder = numbers[arrayCounter++];
boolean primary;
for(long i=minBorder; i<=maxBorder ; i++){
primary = true;
for(long j=2 ; j< Math.sqrt(i) && primary; j++){
if(i%j == 0)
primary = false;
}
if(primary)
System.out.println(i);
}
System.out.println();
testCases--;
}
}
}
(JAVA)
I ve got problem here with this task and dont really know the cause. It throws runtime exception and has problems with input while it works fast and without problems on my computer.
Thanks in advance for given advices on my code.