RosettaCodeData/Task/Arithmetic-geometric-mean/8th/arithmetic-geometric-mean.8th
2023-07-01 13:44:08 -04:00

14 lines
240 B
Text

: epsilon 1.0e-12 ;
with: n
: iter \ n1 n2 -- n1 n2
2dup * sqrt >r + 2 / r> ;
: agn \ n1 n2 -- n
repeat iter 2dup epsilon ~= not while! drop ;
"agn(1, 1/sqrt(2)) = " . 1 1 2 sqrt / agn "%.10f" s:strfmt . cr
;with
bye