Thứ Ba, 3 tháng 5, 2022

DIVISORS Pascal

var n:longint;
procedure nhap;
begin
    readln(n);
end;
function ktnt(n:longint):boolean;
var i:longint;
begin
    for i:=2 to trunc(sqrt(n)) do
        if n mod i = 0 then exit(false);
    exit(true);
end;
procedure giai;
var i,a,j:longint;
        d:int64;
begin
    d:=1;
    for i:=2 to n do
    begin
        if ktnt(i)=true then
        begin
            a:=0;
            j:=i;
            while j<=n do
            begin
                a:=a+n div j;
                j:=j*i;
            end;
        d:=d*(a+1);
        end;
    end;
    writeln(d-1);
end;
begin
    assign(input,'DIVISORS.inp');reset(input);
    assign(output,'DIVISORS.out');rewrite(output);
    nhap;
    giai;
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.