Computer Science, asked by narayanareddymh, 10 months ago

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 vasugiri89
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 anindyaadhikari13
1

\star\:\:\:\sf\large\underline\blue{Question:-}

  • Find whether the given number is prime or not.

\star\:\:\:\sf\large\underline\blue{Program:-}

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