Javascript Prime Number Program - How to Check if a Number is a Prime Number | JavaScript Program

preview_player
Показать описание


WsCube Tech is a leading Web, Mobile App & Digital Marketing company, and institute in India.

We help businesses of all sizes to build their online presence, grow their business, and reach new heights.

All the courses are job-oriented, up-to-date with the latest algorithms and modules, fully practical, and provide you hands-on projects.

📞 For more info about the courses, call us: +91-9024244886, +91-9269698122

✅ CONNECT WITH THE FOUNDER (Mr. Kushagra Bhatia) -

Connect with WsCube Tech on social media for the latest offers, promos, job vacancies, and much more:

--------------------------------------| Thanks |---------------------------
#JavascriptPrograms #JavascriptProjects #ProgramsinJavascript
Рекомендации по теме
Комментарии
Автор

Excellent logic!!! One thing I would add here is the missing of break function. Since it is not added, it shows non-prime number as prime number. For Example:4. Once I added, it worked properly.

ahmedsuhailful
Автор

is video me aapke itne km likes hain or ab to ab super se uppar hogye keep going and never give up!

gamerbhai
Автор

If number <= 1, not prime number
Else if number == 2, prime number
Else ( for = baki code to pata hi hoga.

Mayank_Bisht_MB
Автор

What about if we enter the number as 2?

tawseefaziz
Автор

When we enter 2 then it's give undefined why

gwalkrishna
Автор

Sir 2 number ko run karayiye nhi ho rha undefined output aa rha hai

raistar
Автор

number =2;
Let's assume, i = 2; i<number(2<2 'it's false')
How can i check whether 2 is prime number or not?

sahnawazhussain
Автор

11:11 5 prime number nahi hai aapne bola 😅

debleenaacharya
Автор

let num = 2;
if (num == 1) {
console.log(`${num} is neither prime nor composite`);
} else if (num < 1) {
console.log(`${num} is not a prime number`);
} else {
let isPrime = true;
for (let i = 2; i < num; i++) {
if (num % i === 0) {
isPrime = false;
break;
}
}
if (isPrime) {
console.log(`${num} is a prime number`);
} else {
console.log(`${num} is not a prime number`);
}
}


Updated version of code

prabhatpatel
Автор

Sir 2 number ko run karayiye nhi ho rha undefined output aa rha hai

raistar