#include <bitset>
#include <iostream>

using namespace std;

const unsigned int n = 50;

int main() {
  bitset<n> primes;
  primes.set();
  primes.reset(0); primes.reset(1);

  for (unsigned int k = 2; k*k < n; k++)
    if (primes[k])
      for (unsigned int i = k; i*k < n; i++)
        primes.reset(i*k);

  for (unsigned int k = 0; k < n; k++)
    if (primes[k])
      cout << k << " ";
  cout << endl;

  return 0;
}
