![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
#21
|
|||
|
|||
|
Tarda unos 10 segundos en un portátil PIII celeron 1100
function TForm1.esprimer(Num: integer): boolean; Var Temp,Cont:integer; begin Result:=True; if Num in [1..2] then exit; if (num and 1)=0 then Result:=false; Temp:=Round(Sqrt(Num)); Cont:=3; while (Cont<=Temp) and Result do begin if (Num mod Cont)=0 then Result:=false; inc(cont,2); end; end; procedure TForm1.Button1Click(Sender: TObject); Var Min,Max,i:integer; begin memo1.Lines.Clear; Min:=StrToIntDef(Edit1.Text,1); Max:=StrToIntDef(Edit2.Text,1000000); memo1.Visible:=false; for i:=Min to Max do if EspRimer(i) then memo1.Lines.Add(inttostr(i)); memo1.Visible:=True; label1.Caption:=Inttostr(Memo1.Lines.count); end; |
|
|
|