Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Latihan14;
- {$mode objfpc}{$H+}
- uses
- {$IFDEF UNIX}{$IFDEF UseCThreads}
- cthreads,
- {$ENDIF}{$ENDIF}
- Classes
- { you can add units after this };
- // Program Factorial menggunakan While Loop
- var
- Fac, Num, i: Integer;
- begin
- write('Silahkan tuliskan angka: ');
- readln(Num);
- Fac:=1;
- i:=Num;
- while i > 1 do
- begin
- Fac:= Fac * i;
- i:= i - 1;
- end;
- writeln('Nilai factorial dari ', Num,' is ',Fac);
- writeln('Tekanlah tombol ENTER untuk menutup aplikasi');
- readln;
- end.
Add Comment
Please, Sign In to add comment