Mlente Banget

Pascal – Menghitung Nilai Faktorial

Posted on: November 9, 2008


Tugas pascal menghitung nilai faktorial :

uses wincrt;
function fak(x:word):real;
begin
if x=0 then fak:=1
else fak:=x*fak(x-1);
end;

var n:word;z:real;
begin
writeln(‘=========================================’);
writeln(‘Tugas Algoritma – Nama/NIM Mahasiswa’);
writeln(‘=========================================’);
writeln;
write(‘Hitung Nilai Faktorial dari : ‘);
readln(n);
z:=fak(n);
writeln(‘Nilai Faktorial Dari ‘,n,’ adalah’,z:4:0);
writeln;
writeln(‘=========================================’);
end.

Apabila digambarkan sebagai berikut :

fak(5) => x<>0 => fak=5*fak(4) => fak=5*24 => 120
fak(4) => x<>0 => fak=4*abc(3) => fak=4*6 => 24
fak(31) => x<>0 => fak=3*abc(2) => fak=3*2 => 6
fak(2) => x<>0 => fak=2*abc(1) => fak=2*1 => 2
fak(1) => x=0 => fak=1 => fak=1 => 1
Proses rekursi dihentikan karena b=0 dan abc(5,0)=1.
Bila disimpulkan : fak(5) = 5*(4*(3*(2*(1))))
= 120

Selamat Mencoba

7 Responses to "Pascal – Menghitung Nilai Faktorial"

Thx Bank Eko,,Ajib betul deh….

logone wis ana kae uπŸ˜€

Trims banget…. Ini yang saya cari… pas ada tugas… Maklum Malesan, jadi nyari di internet…πŸ˜€

kami tau kebutuhan andaπŸ˜€

Mas tlng buatin prgrm pascal yg memuat 2 procedure. 1utk mmbaca data, 2utk mncari bil trbsr 1,2 dan 3. Kalo bs scptX krm k emailq mksh.

program tak elok dikau buat, source code dari mano tu, dr kaampung awak yo.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About Me

Unknown unordinary creature
 






November 2008
M T W T F S S
« Oct   Dec »
 12
3456789
10111213141516
17181920212223
24252627282930

Blog Stats

  • 132,030 hits

Your Information

Tracker

%d bloggers like this: