SHARE
TWEET

task1231231231231

a guest Jan 11th, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program Project7;
  2.  
  3. {$APPTYPE CONSOLE}
  4. {$R *.res}
  5.  
  6. uses System.SysUtils;
  7.  
  8. function CalcTask(a, n: Integer): Double;
  9. var
  10.   DenominValues: array of Double;
  11.   i: Integer;
  12. begin
  13.   Result := 0;
  14.   if n <= 0 then raise Exception.Create('Косяк при вводе N');
  15.   if a < 0 then raise Exception.Create('Косяк при вводе A');
  16.   SetLength(DenominValues, n - 1);
  17.   DenominValues[0] := (1 + a);
  18.  
  19.   for i := 1 to Length(DenominValues) - 1 do
  20.   begin
  21.     DenominValues[i] := DenominValues[i - 1] * (a + i + 1);
  22.   end;
  23.  
  24.   for i := 0 to Length(DenominValues) - 1 do
  25.   begin
  26.     Result := Result + 1 / DenominValues[i];
  27.   end;
  28. end;
  29.  
  30. var
  31.   a, n: Integer;
  32.  
  33. begin
  34.   try
  35.     Write('Введите A: ');
  36.     ReadLn(a);
  37.     Write('Введите N: ');
  38.     ReadLn(n);
  39.     WriteLn(CalcTask(a, n));
  40.   except
  41.     on E: Exception do WriteLn(E.ClassName, ': ', E.Message);
  42.   end;
  43.   Readln;
  44.  
  45. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top