Spoj Prime1

import java.util.*;
import java.lang.*;

class Main
{
    public static void main (String[] args)
    {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i = 0;
        long n1=0;
        long n2=0;
        while(i<=n){

            n1  = sc.nextLong();
            n2  = sc.nextLong();
            if(n1==1)
            {
                n1++;
            }
            if((n1-n2)<=100000){

            for(long j=n1;j<=n2;j++){

                int count = 0;

                for(long k=2;k<=j/2;k++){
                    if(j%k==0){
                        count = 1;
                    }
                }
                if(count==0){
                    System.out.println(j);
                }

            }
            }
        }


    }
}
Yucky Yak