Ver Mensaje Individual
  #7  
Antiguo 26-10-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
Bueno, aquí te dejo un poco de código:
Código Delphi [-]
function EsPrimo(n: integer): boolean;
var
  i: integer;
begin
  Result:= FALSE;
  for i:= 2 to Trunc(sqrt(n)) do
    if n mod i = 0 then
      Exit;
  Result:= TRUE;
end;

procedure Primos(n: integer);
var
  i: integer;
begin
  i:= 1;
  while n > 0 do
  begin
    if EsPrimo(i) then
    begin
      dec(n);
      ShowMessage(IntToStr(i)); // Writeln(IntToStr(i));
    end;
    inc(i);
  end;
end;
Responder Con Cita