Senin, 06 Januari 2020

pemrograman pascal Deret bil prima

Program Bilprima;
uses crt;
function factor (n:LongInt) : LongInt;
var
i, temp : LongInt;
begin
temp :=0;
for i := 1 to n do
    if n mod i=0 then inc(temp);
      factor:=temp;
    end;
var x, a, b, c, n : LongInt;
begin
     clrscr;
gotoxy(30,4); writeln(' Deretan Bilangan Prima  ');
gotoxy(30,5); writeln('================================');
gotoxy(3,7); writeln('Jumlah Bilangan Yang Mau Ditampilkan  : ');
repeat
         gotoxy(45,7); clrEol;
          readln(a);
           until (a>=2);
           gotoxy(3,9); writeln('Deret Bilangan Prima  : ');
           b :=1;
           x :=0;
           repeat
              if factor(b) = 2 then
               begin
                write(b,', ');
                write(#8); {backspace}
                inc(x);
     end;
       inc(b);
     until(x=a);
     readln;
end.


Ditulis: Muh Ridho Wachhid S

Tidak ada komentar:

Posting Komentar