Hi everyone, I'm having trouble compiling a sieve of eratosthenes function. I'm using a bitset. The algorithm should work, but the problem lies in the variable bitset size.
This won't compile. If I change the bitset<n> to e.g. bitset<100>, it all compiles well. I've tried const int n, unsigned int n, but nothing works.Code:vector<int> Erat(int n) { bitset<n> sieve; ... }
Can this problem be solved, or should I use another way of initialising the sieve? (for instance vector<bool>, or memset).
What's the fastest way in general to implement a sieve of eratosthenes? (not algorithm wise, but which container and operations to use, etc.)
Thanks in advance!