#include <set>
#include <iostream>

using namespace std;

const unsigned int n = 50;

int main() {
  set<unsigned int> nonprimes{0, 1};

  for (unsigned int k = 2; k*k < n; k++)
    if (!nonprimes.count(k))
      for (unsigned int i = k; i*k < n; i++)
        nonprimes.insert(i*k);

  for (unsigned int k = 0; k < n; k++)
    if (!nonprimes.count(k))
      cout << k << " ";
  cout << endl;

  return 0;
}
