Сформировать массив простых множителей заданного числа — Pascal(Паскаль)

Var A:Array[1..100] of Integer;
    F:Boolean;
    C,N:Integer;
 
Function Prostoe(N:Integer):Boolean;
Var I:Integer;
    B:Boolean;
Begin
  B:=True;
  For I:=2 to N-1 do
   If N mod I = 0 Then B:=False;
   Prostoe:=B;
End;
 
Procedure Find(N:Integer);
Var I:Integer;
Begin
  For I:=2 To N do
  If (N mod I = 0) and Prostoe(I) Then
   Begin
    Inc(C);
    A[C]:=I;
    If N div I = 1 Then
      F:=True;
      Find(N div I);
    If F Then Exit;
   End;
End;
 
begin
 C:=0;
 ReadLn(N);
 Find(N);
 N:=0;
 Repeat                    
 Inc(N);                  
 WriteLn(A[N]:4);      
 Until A[N+1] = 0;    
 ReadLn;
end.

Leave a Comment

− 7 = 1