I keep getting wring answer, I'm using the sieve of eratosthenes algorithim ill post my code below
import java.util.*;
import java.lang.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) throws java.lang.Exception{
// TODO Auto-generated method stub
String input;
String restInput;
int totalTestCases;
int first;
int last;
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
input = r.readLine();
totalTestCases =Integer.parseInt(input);
for (int i = 0; i< totalTestCases; i++ )
{
restInput = r.readLine();
String firstNum = restInput.substring(0, 1);
String finalNum = restInput.substring(2, 3);
first = Integer.parseInt(firstNum);
last = Integer.parseInt(finalNum);
Boolean[] isPrime = new Boolean[totalTestCases + 1];
for(int j = 0; i < totalTestCases; i++)
{
isPrime[i] = true;
}
for (int k = first; i <Math.sqrt(last); i++)
{
if (isPrime[i])
{
for (int l = k * k; i< totalTestCases; l += k)
{
isPrime[i] = false;
}
}
System.out.println(isPrime[i]);
}
System.out.println();
}
}
}