how to determine prime number in java
package prime Algorithm.Testing;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*java practical question
* @author joseph
*/
/**
* @author Samsung Galaxy S4
*
*/
public class PrimeOrNot {
/**
* @param args
*/
static int i,num,flag=0;
public static void main(String[] Lumina) {
// TODO Auto-generated method stub
System.out.println(" To find prime number in java : enter the integer no:");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try {
num=Integer.parseInt(br.readLine());
} catch (NumberFormatException phpexp) {
// TODO Auto-generated catch block
phpexp.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for(i=2;i
{
flag=1;break;
}
}
if(flag==1)
System.out.println("Number is not prime");
else
System.out.println("Number is prime");
}
}
http://belazy.blog.com/