1 / 2
Oct 2011

package spojprimegenerator;
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main(String[] args)throws IOException {
        try{
        int test;
        int start,end,count=0;
        Scanner scan=new Scanner(System.in);
        System.out.println("enter  number of tests" );
        test=scan.nextInt();
        while(test>0)
        {
        System.out.println("enter the starting number");
        start=scan.nextInt();
        System.out.println("enter the last numeber");
        end=scan.nextInt();
        System.out.println("PRIME NUMBERS");
        for(int i=start;i<=end;i++)
        {count=0;
            for(int j=1;j<=i;j++)
            {
                if(i%j==0)
                {
                    count++;
                }
            }
            if(count==2)
            {
                System.out.print(i + "    ");
            }
        }
        test--;
        System.out.println();
        }
        }
        catch(Exception e)
        {
            System.out.println("error");
        }
        }
    }

i am getting a nzec runtime error even though the code is running on netbeans.pls suggest some solution

  • created

    Oct '11
  • last reply

    Oct '11
  • 1

    reply

  • 265

    views

  • 2

    users

package spojprimegenerator;

Remove it + your algo will TLE.

Suggested Topics

Want to read more? Browse other topics in JAVA based languages or view latest topics.