Thứ Ba, 3 tháng 5, 2022

PNUMBER Pascal

var
   p:array[1..2000000] of byte;
   i,j,a,b,t:longint;
procedure sang;
begin
    p[1]:=1;
    for i:=2 to trunc(sqrt(b)) do
        if p[i]=0 then
        begin
            j:=i*i;
            while j<=b do
            begin
                p[j]:=1;
                j:=j+i;
            end;
        end;
end;
begin
    assign(input,fin);reset(input);
    assign(output,fon);rewrite(output);
    read(a,b);
    sang;
    for i:=a to b do
        if p[i]=0 then writeln(i);
    close(input);close(output);
end.

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.