Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project4;
- uses
- Math, System.SysUtils;
- var
- Xpresent: Double;
- Xpast: Double;
- X: Double;
- EPS: Double;
- Product: Double;
- IsCorrect: Boolean;
- i: Integer;
- Begin
- repeat
- Writeln(' Enter X ( -1 < X <= 1) ');
- IsCorrect := True;
- try
- Readln(X);
- if (X <= -1) or (X > 1) then
- begin
- IsCorrect := False;
- Writeln('Incorrect X. Try again');
- end;
- except
- Writeln('Input a number!');
- IsCorrect := False;
- end
- until IsCorrect;
- repeat
- Writeln(' Enter EPS(0 < EPS < 1)');
- IsCorrect := True;
- try
- Readln(EPS);
- if (EPS >= 1) or (EPS <= 0) then
- begin
- IsCorrect := False;
- Writeln('Incorrect EPS. Try again');
- end;
- except
- Writeln('Input a number!');
- IsCorrect := False;
- end
- until IsCorrect;
- Product := X;
- Xpast := X;
- Xpresent := -X * X;
- i := 2;
- while (abs(Xpresent / i - Xpast / (i - 1)) >= EPS) do
- begin
- Product := Product + Xpresent / i;
- Xpast := Xpresent;
- Xpresent := Xpresent * -X;
- i := i + 1;
- end;
- Writeln(' LN(1 + X) = ', Product:4:5);
- Writeln(' N = ', (i - 1));
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement