Prime No program in java
Prime no program
public class Test
{
public static void main(String[] args)
{
int primeno = 5;
int temp = 0;
for(int i = 1; i<=primeno; i++)
{
if(primeno%i==0)
{
temp++;
}
}
if(temp==2)
{
System.out.println("Given no is prime no.");
}
else
{
System.out.println("Given no is not prime no.");
}
}
}
Output is
Given no is prime no.
Comments
Post a Comment