Advertisement
Guest User

dsa

a guest
Sep 22nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.30 KB | None | 0 0
  1. program Project4;
  2.  
  3. uses
  4.    Math, System.SysUtils;
  5.  
  6. var
  7.    Xpresent: Double;
  8.    Xpast: Double;
  9.    X: Double;
  10.    EPS: Double;
  11.    Product: Double;
  12.    IsCorrect: Boolean;
  13.    i: Integer;
  14.  
  15. Begin
  16.    repeat
  17.       Writeln(' Enter X ( -1 < X <= 1) ');
  18.       IsCorrect := True;
  19.       try
  20.          Readln(X);
  21.          if (X <= -1) or (X > 1) then
  22.          begin
  23.             IsCorrect := False;
  24.             Writeln('Incorrect X. Try again');
  25.          end;
  26.       except
  27.          Writeln('Input a number!');
  28.          IsCorrect := False;
  29.  
  30.       end
  31.    until IsCorrect;
  32.    repeat
  33.       Writeln(' Enter EPS(0 < EPS < 1)');
  34.       IsCorrect := True;
  35.       try
  36.          Readln(EPS);
  37.          if (EPS >= 1) or (EPS <= 0) then
  38.          begin
  39.             IsCorrect := False;
  40.             Writeln('Incorrect EPS. Try again');
  41.          end;
  42.       except
  43.          Writeln('Input a number!');
  44.          IsCorrect := False;
  45.  
  46.       end
  47.    until IsCorrect;
  48.    Product := X;
  49.    Xpast := X;
  50.    Xpresent := -X * X;
  51.    i := 2;
  52.    while (abs(Xpresent / i - Xpast / (i - 1)) >= EPS) do
  53.    begin
  54.       Product := Product + Xpresent / i;
  55.       Xpast := Xpresent;
  56.       Xpresent := Xpresent * -X;
  57.       i := i + 1;
  58.    end;
  59.    Writeln(' LN(1 + X) = ', Product:4:5);
  60.    Writeln(' N = ', (i - 1));
  61.    Readln;
  62.  
  63. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement