stevennathaniel

Latihan 14 Free Pascal Console

Jan 3rd, 2014
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.54 KB | None | 0 0
  1. program Latihan14;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Classes
  10.   { you can add units after this };
  11.  
  12. // Program Factorial menggunakan While Loop
  13.  
  14.  var
  15.  
  16.    Fac, Num, i: Integer;
  17.  
  18.  
  19. begin
  20.  
  21.   write('Silahkan tuliskan angka: ');
  22.   readln(Num);
  23.   Fac:=1;
  24.   i:=Num;
  25.  
  26.   while i > 1 do
  27.  
  28. begin
  29.  
  30.   Fac:= Fac * i;
  31.   i:= i - 1;
  32.   end;
  33.  
  34.   writeln('Nilai factorial dari ', Num,' is ',Fac);
  35.  
  36.   writeln('Tekanlah tombol ENTER untuk menutup aplikasi');
  37.  
  38.    readln;
  39.  
  40. end.
Add Comment
Please, Sign In to add comment