Indeed it is. The Sieve of Atkin yields faster performance, but it is a little more complicated and I didn't feel like explaining it. I'm sure there's a Wikipedia article detailing it.
Edit: As much as I wanted to avoid chiming in, I feel compelled to do so. M-Cat, Kaniaz spent a half hour to an hour trying to teach you how not to code, and you are refusing to listen to him. You're the one who needs to learn the language. By the way, the language in question is C++ and not C. ANSI C doesn't have iostream nor does it have the STL. Oh and I hate to say this, but although Kaniaz's advice is correct, M-Cat's original code does compile somehow in GCC (g++), which is the de facto standard compiler. Go figure.
|
|
Bookmarks