Skip to content

Instantly share code, notes, and snippets.

@bl4de
Created May 6, 2013 22:55
Show Gist options
  • Save bl4de/5528930 to your computer and use it in GitHub Desktop.
Save bl4de/5528930 to your computer and use it in GitHub Desktop.
Sieve of Eratosthenes - 1st implementation in C++ @todo: implement properly - current not work
#include <iostream>
#define SCOPE 1000
using namespace std;
int main() {
int tab[SCOPE];
int i = 0;
for (i; i < SCOPE; i++) {
tab[i] = i;
}
// sito eratostenesa
for (i = 0; i < SCOPE; i++) {
if ( tab[i] % 2 == 0 || tab[i] % 3 == 0 || tab[i] % 5 == 0 ) {
// to nie jest liczba pierwsza
} else {
cout << i << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment