1. var a1,an,d,n,i:integer; begin readln(a1,d); readln(n); an:=a1; for i:=2 to n do an:=an+d; writeln('an = ',an); end.
2. function f(a1,d,k:integer):integer; begin if k=1 then f:=a1 else f:=f(a1,d,k-1)+d; end; var a,r,n:integer; begin readln(a,r); readln(n); writeln('an = ',f(a,r,n)); end.
var a1,an,d,n,i:integer;
begin
readln(a1,d);
readln(n);
an:=a1;
for i:=2 to n do an:=an+d;
writeln('an = ',an);
end.
2.
function f(a1,d,k:integer):integer;
begin
if k=1 then f:=a1 else f:=f(a1,d,k-1)+d;
end;
var a,r,n:integer;
begin
readln(a,r);
readln(n);
writeln('an = ',f(a,r,n));
end.
Пример:
3 2
5
an = 11