Số hoàn thiện
PROGRAM hoanthien;
VAR n:INTEGER;
FUNCTION kiemtra(x:INTEGER):BOOLEAN;
VAR tam,i:INTEGER;
BEGIN
tam:=0; kiemtra:=FALSE;
FOR i:= 1 TO (x DIV 2) DO
IF x MOD i = 0 THEN tam:=tam+i;
IF tam = x THEN kiemtra:=TRUE;
END;
BEGIN
writeln('Nhap so can kiem tra ');
readln(n);
IF kiemtra(n) THEN writeln('So ',n,' la so hoan thien')
ELSE
writeln('So ',n,' khong phai la so hoan thien');
readln;
END.
0 nhận xét:
Đăng nhận xét
Click to see the code!
To insert emoticon you must added at least one space before the code.