+ 10
Challenge: How many prime numbers are in 100 000?
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In example: 2, 3, 11, 19, 23, 739. You need to find out how many are there in 100 000, but it would be great if you can go through a greater number, given that sololearn has an execution time limit (for anything other than web). So the trick is to make it fast! Some samples: 1-10: 4 1-100: 25 1-10000: 1229 My try: https://code.sololearn.com/cFt13s2PufPP/#cs
15 Answers
+ 14
Using Sieve of Eratosthenes algorithm :
https://code.sololearn.com/c85hc4aSlXCK/?ref=app
+ 7
My try using c
https://code.sololearn.com/cJ1rV8PUIzC3/?ref=app
+ 7
https://code.sololearn.com/cTMwGZ3gY0D4/?ref=app
+ 5
Answer is: 9592
My Ruby try:
https://code.sololearn.com/cqAXr6IscAgb/#rb
+ 4
9592
+ 2
Hi Muzz, this is my code:
https://code.sololearn.com/c6J9258QPk7o/?ref=app
+ 1
There's only one way to know for sure ;)
+ 1
9,592 ?
+ 1
yep, but that's not the point
+ 1
Two implementations. Second one goes to n=1.000.000 without problem
https://code.sololearn.com/cOAK88Tgl2QJ/?ref=app
+ 1
Bonus : list of all primes <n one liner
https://code.sololearn.com/cjluzxU72b4t/?ref=app
+ 1
https://code.sololearn.com/c47a9XM7pUpk/?ref=app
Here is mine đđđ¤