RosettaCodeData/Task/Arithmetic-geometric-mean/M2000-Interpreter/arithmetic-geometric-mean.m2000
2023-07-01 13:44:08 -04:00

14 lines
422 B
Text

Module Checkit {
Function Agm {
\\ new stack constructed at calling the Agm() with two values
Repeat {
Read a0, b0
Push Sqrt(a0*b0), (a0+b0)/2
' last pushed first read
} Until Stackitem(1)==Stackitem(2)
=Stackitem(1)
\\ stack deconstructed at exit of function
}
Print Agm(1,1/Sqrt(2))
}
Checkit