1 / 2
Jan 2013

MY CODE IS RUNNING PERFECTLY ON ECLIPSE AND BLUE J. HOWEVER COMPILING ON THIS SITE IS GIVING ME RUNTIME ERROR. THE SAME HAPPENED IN CODECHEF. I DON'T UNDERSTAND HOW TO DEAL WITH THIS. PLEASE HELP

	import java.io.*;
	class primegenerator
	{
		public static void main(String args[])
		throws IOException
		{
			int i=0,t=0,check=0;
			long m=0L;
			long n=0L;
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			while(true)
			{
				System.out.println("please enter the number of test cases:t (t<=10)");
				t=Integer.parseInt(br.readLine());
				if(t<=10)
				break;
				else
				System.out.println("value of t cannot exceed 10,try again");
			}
				
			for(i=0;i<t;i++)
			{
				while(true)
				{
					if(check==0)
					{
						System.out.println("enter the value of m");
						m=Long.parseLong(br.readLine());
						if(m>1000000000)
						{
							System.out.println(m);
							System.out.println("value of m cannot exceed 1000000000");
							continue;
						}
						else
							check=1;
					}
					System.out.println("enter the value of n"); 
					n=Long.parseLong(br.readLine());
					if(n>1000000000)
					{
						System.out.println("value of n cannot exceed 1000000000");
						continue;
					}
					if((n-m)>100000 || (n-m)<=0)
					{
						System.out.println("the difference (n-m) must lie between 1 and 100000. \n Try again.");
						continue;
					}
					else
						break;
					
				}
				
				for(long k=m;k<=n;k++)
				{
					int yo=0;
					for(int j=2;j<k;j++)
					{
						if(k%j==0)
						{
							 yo=1;
							 break;
						}
						else
						continue;
					}
					if(yo==0 && k!=1)
					System.out.println(k);
				}
				System.out.println();
			}
		}
	}
  • created

    Jan '13
  • last reply

    Jan '13
  • 1

    reply

  • 342

    views

  • 2

    users

Don't know if this is still true.

Suggested Topics

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