+ 2
8. Write a JavaScript function that accepts a number as a parameter and check the number is prime or not. Note : A prime number
8. Write a JavaScript function that accepts a number as a parameter and check the number is prime or not. Note : A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
3 Respuestas
0
8. Write a JavaScript function that accepts a number as a parameter and check the number is prime or not.
Note : A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
0
var x = prompt("Enter number");
var i = 1;
var count = 0;
for(;i<=x;i++)
{
if(x%i==0){
count++;
}
}
if(count==2){
alert("Prime number");
}else{
alert("Not prime");
}
- 1
write a java script function to get all possible subset with a fixed length ( for example 2 ) combination in an array. sample array :( 1 , 2 , 3) and subset length is 2 expected out put :((2,1), (3,1), (3,2), (3,2,1))