+ 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.

12th Dec 2016, 6:22 PM
Mohameddd Alanzy
Mohameddd Alanzy - avatar
3 odpowiedzi
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.
12th Dec 2016, 6:22 PM
Mohameddd Alanzy
Mohameddd Alanzy - avatar
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"); }
12th Dec 2016, 6:32 PM
Alikhan Suleimen
Alikhan Suleimen - avatar
- 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))
15th Dec 2016, 8:53 PM
Mohameddd Alanzy
Mohameddd Alanzy - avatar