0

prime numbre

please sameone help me creating a javascript code which give all the prime numbers between 2 integars a and b.(a>1,a<b,b<1001)

16th Mar 2022, 7:25 PM
Arafet alaya
Arafet alaya - avatar
3 Respostas
+ 5
Arafet alaya , can you please show your attempt here? this makes it easier to give hints or help you. thanks!
16th Mar 2022, 7:35 PM
Lothar
Lothar - avatar
+ 2
here you can see sir . it's written in french but you can translate it . var a = prompt('Entrer A: '); var b = prompt('Entrer B: '); document.write(" les nombres premiers compris entre " + a + "et " + b + " sont: "); for (var i = a; i <= b; i++) { var X = 0; for (let j = 2; j < i; j++) { if (i % j == 0) { X = 1; } } if (i > 1 && X == 0) { document.write(i + "\n"); } }
16th Mar 2022, 9:19 PM
Arafet alaya
Arafet alaya - avatar
+ 1
Arafet alaya Your code is working perfectly fine.
16th Mar 2022, 11:35 PM
Adil
Adil - avatar