Kamis, 03 November 2011

Program Bilangan Prima Pascal

program jumlahBilanganPrima;
uses crt;
var a,b,c,d,e,jml : integer;
begin
clrscr;
write('batas terendah : '); readln(a);
write('batas tertinggi : '); readln(b);
if a>2 then begin
  jml:=0; a:=a;
end else begin
  jml:=1; a:=3;
end;

if a>b then
begin
  write('Anda salah input'); readln;
  exit;
end else
for a:=a to b do begin
  for c:=2 to a-1 do begin
    if a mod c = 0 then begin
      d:=a;
    end else begin
      e:=a;
    end;
  end;
  if a=d then begin
    c:=a-1;
  end else begin
    write(e:4);
    jml:=jml+1;
  end;
end;
  writeln;
  write('jumlah : ',jml);
  readln;
end.

0 komentar:

Posting Komentar

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | JCPenney Coupons