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

11 lines
180 B
AutoHotkey

agm(a, g, tolerance=1.0e-15){
While abs(a-g) > tolerance
{
an := .5 * (a + g)
g := sqrt(a*g)
a := an
}
return a
}
SetFormat, FloatFast, 0.15
MsgBox % agm(1, 1/sqrt(2))