Skip to content

Instantly share code, notes, and snippets.

@rendon
Created September 27, 2021 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rendon/c05fb2c272668d6aa34bf44534a4781e to your computer and use it in GitHub Desktop.
Save rendon/c05fb2c272668d6aa34bf44534a4781e to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using std::vector;
int main() {
int N;
std::cin >> N;
vector<bool> sieve(N);
int a = 1, b = 1;
sieve[a] = true;
sieve[b] = true;
int c = a + b;
while (c < N) {
sieve[c] = true;
a = b;
b = c;
c = a + b;
}
for (int idx = 1; idx < N; idx++) {
if (!sieve[idx]) {
std::cout << idx << " ";
}
}
std::cout << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment