#include <iostream>
#include <cmath>
#include <vector>

void sieve(int ubound, int primes[]);

int main()
{
    long long n;
    int i;
    std::cout << "Input Number: ";
    std::cin >> n;
    if (n < 2){
        return 1;
    }
    long long upperbound = n;
    std::vector<int> A(upperbound);
    int SquareRoot = sqrt(upperbound);
    sieve(upperbound, A.data());
    for (i = 0; i < upperbound; i++)
    {
        if (A[i] == 1 && upperbound%i == 0)
        {
            std::cout << " " << i << " ";
        }
    }
    return 0;
}

void sieve(int ubound, int primes[])
{
    long long i, j, m;
    for (i = 0; i < ubound; i++)
    {
        primes[i] = 1;

    }
    primes[0] = 0, primes[1] = 0;
    for (i = 2; i < ubound; i++)
    {
        for (j = i*i; j < ubound; j += i)
        {
            primes[j] = 0;
        }
    }
}
