Computer Science, asked by alurushareef6651, 1 year ago

Write a JavaScript to check whether a given No. is prime number or not.

Answers

Answered by parthomsarwade
2

import java.util.*;

class p1

{

public static void main ()

{

Scanner sc=new Scanner(System.in);

int i , n ,c=0;

System.out.println("enter a number");

n=sc.nextInt();

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

{

if(n%i==0)

{

c++;

}//if

}//for

if(c==2)

System.out.println(n+"is a prime number");

else

System.out.println(n+"is not a prime number");

}//void main

}//class


parthomsarwade: don't leave any line
Similar questions