for N = [1000 25000 50000 100000 200000 400000]
    
    tic;
    S = [];
    K = [2:N];
    while ~isempty(K)
        p = K(1);
        m = max(K);
        if p > sqrt(m)
            S = [S K];
            K = [];
        else
            S = [S p];
            q = p;
            while q <= N
                K(K==q) = [];
                q = q + p;
            end;
        end;
    end;
    e = toc;

    tic;
    K = [1:N];
    K(1) = 0;
    for i = [2:N/2+1]
        if K(i) ~= 0
            j = 2*i;
            while j <= N
                K(j) = 0;
                j = j + i;
            end;
        end;
    end;
    T = find(K ~= 0);
    f = toc;

    fprintf('%8d %10.2f %10.2f\n', N, e, f);
    
    if any(S ~= T)
        disp('chyba!');
        return;
    end;
end;
