PROGRAM BILANGAN_FAKTORIAL_FUNCTION;
USES WINCRT;
FUNCTION FAKTORIAL (B:INTEGER):INTEGER;
VAR I,HSL:INTEGER;
BEGIN
CLRSCR;
HSL:=1;
FOR I:=B DOWNTO 1 DO
HSL:=HSL*I;
FAKTORIAL:=HSL;
END;
{PROGRAM UTAMA}
VAR BIL,HASIL:INTEGER;
BEGIN
CLRSCR;
WRITE('INPUT BILANGAN : ');READLN(BIL);
HASIL:=FAKTORIAL(BIL);
WRITELN(BIL,'! = ',HASIL);
READLN;
END.
0 comments:
Post a Comment