You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void Eratosthenes(vector<long int>* primes, long int limit){
vector<bool> primeArray(limit, true);
for( long int p = 2; p < sqrt(limit); p++){
if( primeArray[p]){
for(long int m = p*p; m < limit; m += 2 * p)
primeArray[m] = false;
}
}
primes->push_back(2);
for( long int j = 3; j < limit; j ++ 2 ){
if (primeArray[j])
primes->push_back(j);
}
}
produces this error:
input_line_9:10:42: error: expected ')'
for( long int j = 3; j < limit; j ++ 2 ){
^
input_line_9:10:8: note: to match this '('
for( long int j = 3; j < limit; j ++ 2 ){
^
Interpreter Error:
Btw, that code seems to run just fine on gcc.
The text was updated successfully, but these errors were encountered:
This code has a basic typo in it, the interpreter runs it fine (when edited correctly). Should I delete this, or leave it here in case I reproduce a similar error?
Ok so here might be a better example, that's not a typo
long int e10(vector<long int>* primes, int limit){
long int total = 0;
vector<long int>::iterator: i = primes->begin();
while( *i < limit ){
total += *i;
i++;
}
return total;
}
Here the interpreter says:
input_line_14:2:51: error: function definition is not allowed here
long int e10(vector<long int>* primes, int limit){
^
Interpreter Error:
Eg, this code:
produces this error:
Btw, that code seems to run just fine on gcc.
The text was updated successfully, but these errors were encountered: