13 Kasım 2012 Salı

Asal mi degil mi

Girilen bir sayinin asal olup olmadığını kontrol eder
program asalmi(input,output);
Label here;
var
a,i : integer;

begin
writeln('Sayiyi Giriniz');
readln(a);
if a>2 then
    begin
          for i:=2 to A-1 do
          begin
             if A mod i=0 then
             begin
             writeln('Sayi Asal Degildir.',i,' sayisina tam bolunur');
             Goto here;
             Break;
             end
          end;
          writeln('Sayi Asaldir');
          goto here
    end
    else
     if A=2 then
     writeln('sayi asaldir')
     else
     writeln('1 den buyuk bir sayi giriniz');
    here:readln()
end.

Hiç yorum yok:

Yorum Gönder