package ua.nure.jfn.task1;

public class Part3 {

    public static void main(String[] args) {
        for (int n : getPrimeNumbers(Part2.parseInt(args[0])))
            System.out.printf("%d ", n);
    }

    public static int[] getPrimeNumbers(int n) {
        if (n == 0) return new int[0];

        int[] primes = new int[n];
        primes[0] = 2;

        for (int i = 3, c = 1; c < n; i += 2)
            if (isPrime(i))
                primes[c++] = i;

        return primes;
    }

    public static boolean isPrime(int n) {
        if (n <= 1)
            return false;

        for (int i = 2; i * i <= n; i++) // same as i < sqrt(n)
            if (n % i == 0)
                return false;

        return true;
    }
}
