RosettaCodeData/Task/Arithmetic-geometric-mean/PL-I/arithmetic-geometric-mean.pli
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

13 lines
424 B
Text

arithmetic_geometric_mean: /* 31 August 2012 */
procedure options (main);
declare (a, g, t) float (18);
a = 1; g = 1/sqrt(2.0q0);
put skip list ('The arithmetic-geometric mean of ' || a || ' and ' || g || ':');
do until (abs(a-g) < 1e-15*a);
t = (a + g)/2; g = sqrt(a*g);
a = t;
put skip data (a, g);
end;
put skip list ('The result is:', a);
end arithmetic_geometric_mean;