## Eratosthenes (AWK).
BEGIN {
    start = systime()
    # srand(); start = srand()
    maxarray = 10000
    maxprime = ARGV[1]
    for (base = 2; maxprime >= base; base += maxarray) {
        arraysize = (maxarray < maxprime - base + 1) ? maxarray : maxprime - base + 1
        delete arr
        for (i = 2; (base + arraysize) / 2 > i; ++i) {
            if (base <= i)
                k = i * 2
            else if (base % i)
                k = int(base / i + 1) * i
            else
                k = base
            for (; base + arraysize > k; k += i)
                arr[k - base] = ""
        }
        rs = ""
        for (i = 0; arraysize > i; ++i)
            if (!(i in arr))
                rs = rs (base + i) "\n"
        printf "%s", rs
    }
    # srand(); printf "%gsec.\n", srand() - start >"/dev/stderr"
    printf "%gsec.\n", systime() - start >"/dev/stderr"
}