Write a Program to input a number and check whether the number is prime or not
Answers
Answered by
2
Class Prime
{
void get (int n)
{
int count=0;
for(int a=1;a<=n;a++)
{
If (n%a==0)
{
count++;
}
If(count==2)
System.out.print(n+ "is a prime number");
else
System.out.print(n+" is not a prime number.");
}
}
{
void get (int n)
{
int count=0;
for(int a=1;a<=n;a++)
{
If (n%a==0)
{
count++;
}
If(count==2)
System.out.print(n+ "is a prime number");
else
System.out.print(n+" is not a prime number.");
}
}
Similar questions