- Function pangkat(a : integer; n : integer):integer;
if n = 0 then
begin
pangkat := (1);
end
else
begin
pangkat := (a*pangkat(a, n-1));
end;
endfuction - Algoritma Menentukan Deret Bilangan Fibonacci
Deklarasi:
i, n, fibonacci(i): integer
Deskripsi:
input(n)
if i=0 atau i=1 then
cetak “fibonacci(i)=i”
else
while i>1 dan i=n do
fibonacci(i)=fibonacci(i-1)+fibonacci(i-2)
cetak fibonacci(i)
i=i+1
end - Function gcd(m, n : integer) : integer;
var r : integer;
begin
r := m mod n;
while (r <> 0) do begin
m := n;
n := r;
r := m mod n;
end;
gcd := n;
end;
Fibonacci := Fibonacci(n - 1) + Fibonacci(n - 2);
Wednesday, November 30, 2016
Filled Under:
Algoritma Rekursif
By
Adj
Dated
8:25:00 AM
Subscribe to:
Post Comments (Atom)
0 komentar:
Post a Comment