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/
Good day! This is kind of off topic but I need some
ReplyDeleteadvice from an established blog. Is it very hard
to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking about making my own but I'm not sure where to begin. Do you have any tips or suggestions? Many thanks
Here is my site :: visit here