Computer Science, asked by gemsking80, 3 months ago

Q1.Write a program to calculate and find whether inputed number is prime number or not?
please write full program​

Answers

Answered by kamalrajatjoshi94
1

Answer:

import java.util.*;

public class Prime

{

public static void main(String args[ ])

{

Scanner in=new Scanner(System.in);

int n,num=0,a,c=0;

System.out.println("Enter the number");

n=in.nextInt();

for(a=1;a<=n;a++)

{

if(n%a==0)

c++;

}

if(c==2)

System.out.println("Prime number");

else

System.out.println("Not a Prime number");

}

}

Similar questions