+ 1

Prime numbers < 1000

Hello can anyone print out the code to have the first prime numbers in c++ all must be below 1000 And also a second code showing all the 100 prime numbers. Thanks

21st Nov 2018, 5:07 PM
Christopher D. Museme
Christopher D. Museme - avatar
3 Respuestas
21st Nov 2018, 5:17 PM
Stefan Secrieru
Stefan Secrieru - avatar
0
Hey Stefan i am not getting the logic could you please tell me what you did in this code
22nd Nov 2018, 10:20 AM
Ash
0
Ash I used the Sieve of Erathosthenes. You start by assuming that every number is a prime one. When you find a number that is prime you must mark every multiple of that number as not being prime (because they divide by your prime number). So if prime[i] is prime( in my program its value is false) you print i.
22nd Nov 2018, 12:43 PM
Stefan Secrieru
Stefan Secrieru - avatar