i did some experiment let's check it #7
Conversation
There was a problem hiding this comment.
Hey, thanks so much for taking the time to look at my code and suggest improvements I really appreciate it!
You made a great point about adding a primeCount variable, I've gone ahead and included that in the updated version. It's a nice touch to show the total at the end.
After reviewing both approaches, I've decided to stick with the Sieve of Eratosthenes since it has better time complexity (O(n log log n) vs O(n√n)) for larger inputs, even though your trial division solution is clean and works well too.
The main bug I fixed was the missing vector isPrime(n + 1, true) declaration that was causing the compile error in my original code. I also cleaned up the output formatting.
Thanks again for the benchmark results and for sharing your approach it was helpful to see the comparison!
There was a problem hiding this comment.
I am also learning and I am a beginner, but today’s beginner is tomorrow’s future. I am trying to gather some programmer friends so we can make big projects together and contribute to big projects. That’s it.
if u intarested then feel free to join :D https://discord.gg/x9WukYXv
:D