find the given number is prime number or not. it has no factor other than 1 and itself. Ec;- 5,11,17
Answers
Answered by
0
Answer:
than 1 that can only be divided by itself and 1. The smallest prime numbers are 2, 3, 5, 7, 11, 13, 17, 19 and 23.
Answered by
1
- Find whether the given number is prime or not.
import java.util.*;
class Prime
{
public static void main(String s[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
int n=sc.nextInt();
int x=true;
for(int i=2;i<n;i++)
{
if(n%i==0)
{
x=false;
break;
}
}
if(x)
System.out.println("Prime number.");
else
System.out.println("Not a Prime number.");
}
}
Similar questions
Science,
5 months ago
History,
5 months ago
Social Sciences,
10 months ago
Computer Science,
1 year ago
Biology,
1 year ago