{(c) 2001 Emur http://emur.org} program Prvocisla; uses crt,dos; var x,y,xzaokr,i: longint; {i=0 .. jen prvocislo, i=1 .. neni} s,s2: string; {posledni cilice} od,az: longint; {meze} h,m,sek,ss: word; {casove promene} cas,cas2: real; pocet: longint; {pocet prvocisel} BEGIN clrscr; pocet:=0; writeln(' Emurovo rychle pocitani prvocisel'); write(' Chci znat prvocisla od: ');read(od); gotoxy(37,2); write('do: '); readln(az); gettime(h,m,sek,ss); cas:=(ss+sek*100+m*60*100)/100; {mereni casu} for x:=od to az do {zaciname pocitat;-)} begin i:=0; str(x,s); s2:=copy(s,ord(s[0]),1); if (x<>5) and (x<>2) then {je posl cislice suda nebo 5?} if (s2='0') or (s2='2') or (s2='4') or (s2='5') or (s2='6') or (s2='8') then continue; xzaokr:=trunc(sqrt(x)); {staci delit jen cislem do odmocnina z x} if x=2 then {vypise 2 jako prvocislo} begin write(x:10); pocet:=pocet+1; end else for y:=2 to xzaokr do if x mod y=0 then begin i:=1; break; end {neni prvocislo} else if y=xzaokr then if i=0 then {je prvocislo} begin write(x:10); pocet:=pocet+1; end; end; gettime(h,m,sek,ss); cas2:=(ss+sek*100+m*60*100)/100; {cas konec} writeln;write(' ',pocet,' prvocisel jsem spocital za ' ,cas2-cas:2:2,' sek. (C) Emur 2001'); sound(300); delay(150); nosound; {zaver - ton} readkey; END.