Skip to content
Sign UpLog In
Profile icon

Eric Wang

@eric_wang
I do the thing
Repls
Community
eric_wang
eric_wang
shared a Post
3 years ago
Optimized Sieve of Eratosthenes.
Optimized Sieve of Eratosthenes Given two naturals, start and end, print all primes between start and end inclusive. Preconditions 1 <= start <= end
Optimized Sieve of Eratosthenes.
C++
xxpertHacker
xxpertHacker
Why does the code look more like C, but use C++ headers? Might I ask, what is the difference between `, , and when compared to , , and `? I wonder if you could make a simple, but ridiculously inefficient recursive to determine if something is a prime or not. Like, I'm not even joking, can you? If you care about speed, since you wrote "Optimized" in the title, I might be able to optimize it.3 years ago
Highwayman
Highwayman
Maybe it’s not that 6, 12, and 18 are be considered too much, but that the iterations 1, 2, and 3 are being considered too much? Too an extent of course. I’m no programmer lol. Edit: sry not 1,2,3 ; I mean 2,4,6. Edit: oh here we go. Generate the set S of integers between start and sqrt(start), take out the multiples of the first element, creating set S1. Then take the next number in S1 and do the same, making S2, then again with S2 and so on and so forth....?3 years ago
Highwayman
Highwayman
Noiice3 years ago