Here is a Program to find a number is prime or not
import java.io.*;
class prime
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(" Enter any no,");
int a = Integer.parseInt(br.readLine());
int fac=0;
for(int i =2;i{
if(a%i==0)
fac=1;
break;
}
if(fac==0)
System.out.println("Prime Number");
else
System.out.println("Not Prime Number");
}
}
Subscribe to:
Post Comments (Atom)
2 comments:
why had you had taken fac = 1?
tell please
instead of doing fac++ he has taken fac =1...
Post a Comment