* "F" (file) specs define files and other i/o devices
FARMstF1 UF E K Disk Rename(ARMST:RARMST)
* "D" specs are used to define variables and parameters
* The "prototype" for the program is in a separate file
* allowing other programs to call it
/copy cust_pr
* The "procedure interface" describes the *ENTRY parameters
D getCustInf PI
D pCusNo 6p 0 const
D pName 30a
D pAddr1 30a
D pAddr2 30a
D pCity 25a
D pState 2a
D pZip 10a
/free
// The "chain" command is used for random access of a keyed file
chain pCusNo ARMstF1;
// If a record is found, move fields from the file into parameters
if %found;
pName = ARNm01;
pAddr1 = ARAd01;
pAddr2 = ARAd02;
pCity = ARCy01;
pState = ARSt01;
pZip = ARZp15;
endif;
// RPG makes use of switches. One switch "LR" originally stood for "last record"
//LR actually flags the program and its dataspace as removable from memory.
*InLR = *On;
/end-free
Объяснение:
var
a, b: real;
n: integer;
function arif_mem(a, b: real; n: integer): real;
begin
if n = 1 then arif_mem := a;
if n > 1 then arif_mem := arif_mem(a, b, n - 1) + b;
end;
function arif_sum(a, b: real; n: integer): real;
begin
if n = 1 then arif_sum := a;
if n > 1 then arif_sum := arif_sum(a, b, n - 1) + arif_mem(a, b, n);
end;
begin
write('введите первый член прогрессии:');
readln(a);
write('введите разность прогрессии:');
readln(b);
write('введите номер члена прогрессии:');
readln(n);
writeln(n, '-й член прогрессии равен :', arif_mem(a, b, n):8:2);
writeln('сумма ', n, ' членов прогрессии равна :', arif_sum(a, b, n):8:2);
end.
количество исходов: