RSS

Menentukan Bilangan Prima – FPC

04 Okt

Program BPrima;
uses crt;

type
larik = array [1..100] of integer;

var
Bil,i,sb,jfb : integer;

KBil : String[25];
fb : larik;

begin
clrscr;

REPEAT
BEGIN
CLRSCR;
WRITE (‘Masukan Bilangan (1..1000) : ‘);READLN(Bil);
END;
UNTIL (Bil >= 1 );

jfb := 0;
for i:= 1 to Bil do
begin
sb := Bil Mod i;
if sb = 0 then
begin
jfb := jfb + 1;
fb[jfb] := Bil DIV i;
end;
end;

write(‘Faktor Bilangan ‘,Bil,’ adalah ‘);
for i:= jfb downto 1 do
begin
write (fb[i],’, ‘);
end;
writeln(”);

for i:= jfb downto 1 do
begin
writeln(Bil,’ : ‘,fb[i],’ = ‘,Bil Div fb[i]);
end;
writeln(”);

KBil := ‘Bilangan Prima';
if jfb > 2 then KBil := ‘Bukan Bilangan Prima';

writeln(‘Bilangan ‘,Bil,’ adalah ‘,KBil);
writeln(”);

end.

About these ads
 
Tinggalkan komentar

Ditulis oleh pada Oktober 4, 2011 in Free Pascal

 

Berikan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logout / Ubah )

Twitter picture

You are commenting using your Twitter account. Logout / Ubah )

Facebook photo

You are commenting using your Facebook account. Logout / Ubah )

Google+ photo

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
Ikuti

Get every new post delivered to your Inbox.

%d blogger menyukai ini: