initial commit

This commit is contained in:
2023-07-16 13:23:25 +00:00
commit c3fa5367c3
85 changed files with 4921 additions and 0 deletions

27
C++/lesson2/task6.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <cmath>
#include <iostream>
#include <vector>
int main() {
int n;
std::cin >> n;
if (n < 0) {
std::cout << "You are a bad person!\n";
return 0;
}
std::vector<bool> values(n + 1, true);
int root = sqrt(n);
for (unsigned int i = 2; i <= root; i++) {
if (values[i]) {
std::cout << i << '\n';
for (int j = i * i; j <= n; j += i) {
values[j] = false;
}
}
}
for (int i = root + 1; i <= n; i++) {
if (values[i]) {
std::cout << i << '\n';
}
}
}