Check Prime Number Program in JavaScript | Find Prime Numbers in JavaScript [Hindi]

preview_player
Показать описание
Welcome guys, We will see Program on how to find Prime Number in Javascript in Hindi. We will see prime number program in javascript using function and also we will see prime number program in javascript using for loop.
A prime number has only two factors: 1 and itself.
A composite number has more than two factors. The number 1 is neither prime nor composite. The prime numbers between 2 and 31 are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 and 31 since each of these numbers has only two factors, itself and 1.

If you like this video please LIKE, SHARE and SUBSCRIBE my channel :)
Рекомендации по теме
Комментарии
Автор

lo ji....ek aur wow factor wala video...;-D
thanks a lot
keep it up n keep smiling ;-D

reshmar
Автор

if i enter a number 2 so i have no print any output why?

parmargautam
Автор

Can we are check the number is prim or not in output
I mean write a program to check the number in prim or not input by user.

dineshjaiswal
Автор

Nice video. What if we want a program where we want to print values from ex: between 2 to 200. This can't be applied then.

akritiyadav
Автор

if i check isprime(9) its showing 9 is a prime number ....check it once and give brief explanation on that.

pallavireddypallu
Автор

There is some problem in coding because the number divisible by 3, 5, 7 shows as a prime number.pls help

ansumanmohanty
Автор

If a user want to enter number and check it... Then text box show ho tb kese krege

bhawanadak
Автор

for loop only for if statement not for else statement so put one more parenthesis after if statement and remove one parenthesis after else statement.


<script>
  isprime(27);
  function isprime(num){


    var i;
    var num;
    
    for( i=2; i<num; i++){


      if(num%i===0){
        

        return false;
      }
    }
      

      return true;
    }
  
  
</script>

mohdshameem
Автор

wow its AWESOME, plz make more videos on such program :)

sachinhd
Автор

what if we assign a value 2 then its not work

RohitSharma-ojre
Автор

javascript prog to find prime num in a user given range (using promt & alert tags)

soletune
Автор

This code is wrong if u enter 9 in function the output is prime but 9 % 3 = 0

asharkazi
Автор

ok..done my problem


var prime = parseInt(prompt("Enter Any Number: "));

function isprime(prime)
{
if (prime === 1) {
document.write(prime + " is neither prime nor composite number. ")
}
for (var i = 2; i <= prime; i++) {
if (prime % i == 0) {
document.write(" This " + prime + " number is not a prime number.");
break;
}
else {
document.write(" This " + prime + " number is a prime number.");
break;
}


}
}
isprime(prime);

parmargautam
Автор

That's not correct..
Right ans is-
Function isPrime(num) {
If(num<2) return false;
For(let i=2;i<num;I++){
If(num%i===0) return false}
Return true;
}isPrime(58769);

// u can replace false with not a prime no. And true with prime no.

rmt
Автор

Bhai prompt box k sath kaise kare yeah batao 🙏🙏

sankalpbhola
Автор

even odd ka funda hai bhai na ki prime ka

SantoshSingh
Автор

This video gives us wrong information.check any odd no. which is not prime.This code shows odd no. as a prime no.

devrajdpk
Автор

This function showing 9 is a prime number.

raj
Автор

Thanks you, but this method does not work. If you try the number 51 it will tell you that it is a prime number. And it's not a prime number
.

tslqs
Автор

but numbers which are odd like 15 are also prime numbers, it is showing that it is not a prime number

garimagarg