Program Numero_Primo (fichero,output);
 
Var
  Fichero: Text;
  Numero, Coord_X, Coord_Y: Integer;
  final,Primo: Boolean;
  h:char;
 
Function numeroprimo(numero:integer):boolean;
var
  valor,resto_div: integer;
begin
  valor := 1; resto_div :=1;
  if numero = 1 then
    primo := true
  else
    begin
      while resto_div <> 0 do
      begin
        valor := valor +1;
        resto_div:= (numero mod valor);
      end;
      if numero = valor then numeroprimo := true
      else numeroprimo := false;
    end;
end;
 
Procedure salida_pantalla(numero1:integer;var primo:boolean);
Begin
  writeln;
  Writeln('********************************************************');
  Writeln('* Nombre del Alumno: Jos‚ Antonio Barreiro Calvi¤o *');
  Writeln('* Asignatura: Fundamentos de Programaci¢n (FP I) *');
  Writeln('* Curso: ITIG (Ingenieria T‚cnica Inform tica Gesti¢n) *');
  Writeln('* N£mero de Matr¡cula: bd003 *');
  Writeln('********************************************************');
  writeln;
  if primo = false then
    writeln (output,'El N£mero: ',numero1, ' no es n£mero primo en la pos X:', coord_x, ' pos Y:', coord_y)
  else
    writeln (output,'El N£mero: ',numero1, ' es n£mero primo en la pos X:', coord_x, ' pos Y:', coord_y);
End;
 
{ Cuerpo Principal. }
Begin
  primo := true; coord_x:=0; coord_y := 1;
  assign (fichero, 'numeros.txt');
  reset(fichero);
  repeat
    coord_x:=coord_x+1;
    read(fichero,numero);
    primo:=numeroprimo(numero);
    if (EOF(fichero)) and (numero = 0) then
    begin
      writeln;
      writeln('Se ha llegado al final de fichero. Pulse tecla ....');
    end
      else
      salida_pantalla (numero,primo);
    if eoln(fichero) then
    begin
      coord_x := 0; coord_y := 1;
    end;
  until (eof(fichero)) and (numero = 0);
  close (fichero);
End.