RosettaCodeData/Task/Arithmetic-geometric-mean/F-Sharp/arithmetic-geometric-mean.fs

6 lines
161 B
Forth
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
let rec agm a g precision =
if precision > abs(a - g) then a else
agm (0.5 * (a + g)) (sqrt (a * g)) precision
printfn "%g" (agm 1. (sqrt(0.5)) 1e-15)