Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int numer = 0;
- int dzielnik = 2;
- vector <int> sito(1, 2); // Pierwszy domyślny element w sicie - liczba 2
- // Wypelniamy zbior liczbami od 2 do liczba
- for (int x = 3; x <= liczba; x++)
- sito.push_back(x);
- // Usuwanie liczb nie-pierwszych | Pierw dzielniki liczby 2, potem liczby 3, (czworka po drodze odpadla), 5..
- do
- {
- for (int x = 2; x < sito.size(); x++)
- if (sito[x] % dzielnik == 0)
- sito.erase(sito.begin()+x);
- dzielnik = sito[numer++];
- }
- while (dzielnik != sito.back());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement