How can I find prime numbers through bit operations in C++?
How can I find prime numbers through bit operations in C++? I think the way to do this is to not think of the bitset as its numerical representation as we normally do, but to think of it at a list of numbers. So the bitset 1111 would represent the numbers 1, 2, 3, and 4. Now if we say that a '1' represents prime and a '0' represents not prime, we can make a sieve as follows. Set all the bits to 1 (I'm going to use 16 bits that represent the integers 1 through 16) 1111 1111 1111 1111 I know that one is not prime, so I'm setting it to zero. 0111 1111 1111 1111 Now, I know that the next '1' I