Exploring the Ocean of Science

Assalamualaikum,
Uhmmm…ini salah satu program pascal untuk membuat deret fibonacci (0 1 1 2 3 5 8 ….) dengan metode array

Met Mencoba…^_^

Program Fibonacci;

uses crt;
var
fib : array[1..100] of integer;
k,s : integer;

begin
clrscr;
write(‘Masukan banyaknya deret : ‘);
readln(k);
for s:=0 to k do
begin
if s <= 1 then
begin
fib[s] := s;
write(fib[s]:3);
end
else
begin
fib[s] := fib[s-1] + fib[s-2];
write(fib[s]:3);
end;
end;
readln;
end.

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

%d bloggers like this: