Вычислить сумму n первых членов арифметической прогрессии — Pascal(Паскаль)

program sd;

uses crt;

var
  n, a, t: integer;

function sum(a, n, t: integer): integer;
begin
  if t > 1 then
    result := result + sum(a, n, t - 1) + n
  else if (t = 1) then
    result := a;
end;

begin
  read(a);
  read(n);
  read(t);
  write(sum(a, n, t));

end.

Leave a Comment

5 + 5 =