RosettaCodeData/Task/Jensens-Device/Simula/jensens-device.simula

24 lines
546 B
Plaintext

comment Jensen's Device;
begin
integer i;
real procedure sum (i, lo, hi, term);
name i, term;
value lo, hi;
integer i, lo, hi;
real term;
comment term is passed by-name, and so is i;
begin
integer j;
real temp;
temp := 0;
for j := lo step 1 until hi do
begin
i := j;
temp := temp + term
end;
sum := temp
end;
comment note the correspondence between the mathematical notation and the call to sum;
outreal (sum (i, 1, 100, 1/i), 7, 14)
end