0

Prime number

Can I write a code in c++ or python that outputs all prime numbers less than the input n?

31st Jan 2019, 9:59 PM
luca
5 Answers
+ 9
Yes, off course you can! 👍
31st Jan 2019, 10:03 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 7
luca I hope, this will help you! 👍 https://code.sololearn.com/cIq5PZ7yhZlQ/?ref=app
1st Feb 2019, 9:06 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 5
You need to understand the algorithm. Search this: "Sieve Of Erathnostenes" and this will help you.
1st Feb 2019, 1:30 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
how can i?
31st Jan 2019, 10:29 PM
luca
+ 1
For (int i=2, o = 0; i<n;++i) { for(int j=2;j*j<=n;++j) If (i%j==0) o = 1; If(!o) cout << i << endl; }
1st Feb 2019, 12:08 AM
Bartosz Pieszko
Bartosz Pieszko - avatar