import java.io.*;
public class prime
{
public static void main(String [] y)
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number.. ");
String x=null;
boolean b=true;
try
{
x=br.readLine();
}
catch(IOException io)
{
System.out.println(io);
}
int z=Integer.parseInt(x);
for(int i =2;i<=Math.sqrt(z);i++)
{
if(z%i==0)
b=false;
}
if(b==true)
System.out.println("number is prime "+z);
else
System.out.println("number is not prime "+z);
}
}
Showing posts with label prime number.java code. Show all posts
Showing posts with label prime number.java code. Show all posts
Thursday, March 26, 2009
java code to find prime numbers
Labels:sreejithrs,nojamp,karakulam,sreejith rs
prime number.java code
Subscribe to:
Posts (Atom)