Minggu, 01 April 2012

Mencari bilangan Prima

Program Bilangan_Prima;
uses crt;
var a,b,c,d,e:longint;
procedure deret_prima(x,y,z:longint);
begin
writeln('2':7);
for x:=3 to z do
begin
for y:= 2 to x-1 do
begin
if x mod y = 0 then begin
d:=x ; end else begin e:=x; end;end;
if x=d then
begin
y:= x-1;
end else
writeln(e:7);
end;
end;
begin
clrscr;
write('bilangan prima sampai berapa? '); readln(c);
deret_prima(a,b,c);
readln;
end.

Tidak ada komentar:

Poskan Komentar