Arithmetic-geometric mean: Difference between revisions
Content deleted Content added
Added Uiua solution |
PascalABC.NET |
||
Line 2,580: | Line 2,580: | ||
end.</syntaxhighlight> |
end.</syntaxhighlight> |
||
Output is as long as the C example. |
Output is as long as the C example. |
||
=={{header|PascalABC.NET}}== |
|||
<syntaxhighlight lang="delphi"> |
|||
function agm(a,g: real; eps: real := 1e-10): real; |
|||
begin |
|||
var an := (a + g) / 2; |
|||
var gn := Sqrt(a * g); |
|||
while Abs(an - gn) > eps do |
|||
(an,gn) := ((an + gn) / 2, Sqrt(an * gn)); |
|||
Result := an; |
|||
end; |
|||
begin |
|||
Print(agm(1, 1 / Sqrt(2))) |
|||
end. |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
0.847213084835193 |
|||
</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |