uses crt; const // row=1; n = 75; // 1: B>0 row=2; n = 75; // 2: B<0 e=1e-12; var i : integer; x : array[1..n] of longint; x_st : string; k, m : longint; process_end : boolean; procedure output_info; begin clrscr; writeln; if row=1 then writeln(' B > 0 ') else writeln(' B < 0 '); writeln; str(n,x_st); writeln(' n = ',x_st,' (first members of the row)'); writeln; end; procedure Pellya_1; // B > 0 var B, y_Z : longint; y0, yk, x0, D : real; solution : boolean; begin k:=2; i:=1; output_info; write('x=('); repeat if (k mod 4 = 2) then begin solution:=false; m:=1; {// m in [1; k/2]} repeat B:=sqr(m)+k; y0:=-sqrt(B/(m+2)); yk:=-y0; y_Z:=round(y0); if y_Zy0) and (y_Z<=yk)) and (solution=false) do begin D:=sqr(y_Z)*(sqr(m)-4)+4*B; if D>=0 then begin x0:=1/2*( m*y_Z + sqrt(D) ); if frac(x0)k/2) or (process_end=true); if (solution=false) then begin x[i]:=k; write(' ',x[i],','); i:=i+1; end; end; k:=k+1; until (i>n) ; writeln(')'); writeln; end; procedure Pellya_2; // B < 0 var B, y_Z : longint; y0, yk, x0,D : real; solution : boolean; t_st : string; begin k:=1; i:=1; output_info; write('x=('); repeat solution:=false; m:=3; repeat B:=-sqr(m)-k; // solution of I-type y0:=-sqrt(abs(B)/(m-2)); yk:=-sqrt(4*abs(B)/(sqr(m)-4)); y_Z:=round(y0); if (y_Zy0) and (y_Z<=yk)) do begin D:=sqr(y_Z)*(sqr(m)-4)+4*B; if D<0 then begin str(D:2:2, t_st); end else begin x0:=1/2*(m*y_Z + sqrt(D)); if abs(frac(x0))2*k+8) or (process_end=true); if (solution=false) and (k mod 4 <> 1) and (k mod 9 <> 3) and (k mod 9 <> 6) then begin x[i]:=k; write(' ',x[i],','); i:=i+1; end; k:=k+1; until (i>n); writeln(')'); writeln; end; procedure output_txt; var row_st: string; i : integer; begin row_st:='x={'; for i:=1 to n do begin str(x[i],x_st); row_st:=row_st + x_st+', '; end; row_st:=row_st + '}'; output_info; // for i:=1 to n do writeln('x[',i,']=',x[i]); writeln; writeln(row_st); writeln; end; begin {main} case row of 1: Pellya_1; { B = m*m + k > 0} 2: Pellya_2; { B = - m*m - k < 0} end; // output_txt; // data output after full calculation of the series end.