Jump to content

Arithmetic-geometric mean: Difference between revisions

m
→‎{{header|BASIC}}: Dialects in alphabetic order.
(add RPL)
m (→‎{{header|BASIC}}: Dialects in alphabetic order.)
Line 397:
 
=={{header|BASIC}}==
==={{header|BASIC}}===
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">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</syntaxhighlight>
{{out}}
<pre>
.8472131
</pre>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">print AGM(1, 1 / sqr(2))
Line 505 ⟶ 486:
160 LET AGM=A
170 END DEF</syntaxhighlight>
 
==={{header|BASICQuickBASIC}}===
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">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</syntaxhighlight>
{{out}}
<pre>
.8472131
</pre>
 
==={{header|True BASIC}}===
512

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.