Heres my code:
public class Main{
static Hashtable htChecker = new Hashtable();
public static void main(String[] args) throws Exception {
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(System.in));
int num = Integer.parseInt(reader.readLine());
String input[] = new String[num];
for(int x = 0 ; x < num ; x ++)
{ input[x] = reader.readLine();}
for(int x = 0 ; x < num ; x ++)
{
StringTokenizer st = new StringTokenizer(input[x]);
getPrime(st.nextToken(), st.nextToken());
}
}
private static void getPrime(String token1, String token2)
{
int input1 = Integer.parseInt(token1);
int input2 = Integer.parseInt(token2);
boolean isPrime = true;
if(input1 % 2 == 0)
{ input1 += 1; }
if(input1 == 1)
{ System.out.println(input1+1); input1 += 2; }
for(int x = input1 ; x <= input2; x+=2)
{
if(htChecker.contains(x))
{ System.out.println(x); }
else
{
int halfX = x/2;
isPrime = true;
for(int y = 2 ; y <= halfX ; y++)
{
if(x % y == 0)
{ isPrime = false; break;}
}
if(isPrime)
{ System.out.println(x); htChecker.put(x, x); }
}
}
System.out.println();
}
}
what else can i do to make this faster? >_<
im always getting 'time limit exceeded'