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

13 lines
172 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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