RosettaCodeData/Task/Arithmetic-geometric-mean/QuickBASIC/arithmetic-geometric-mean.b...

13 lines
172 B
Plaintext

PRINT AGM(1, 1 / SQR(2))
END
FUNCTION AGM (a, g)
DO
ta = (a + g) / 2
g = SQR(a * g)
SWAP a, ta
LOOP UNTIL a = ta
AGM = a
END FUNCTION