Skip to content

Instantly share code, notes, and snippets.

@grondilu
Created January 18, 2014 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save grondilu/8489288 to your computer and use it in GitHub Desktop.
Save grondilu/8489288 to your computer and use it in GitHub Desktop.
attempt to simplify http://rosettacode.org/wiki/Arithmetic-geometric_mean#Perl_6. For some reason this code fails to acknowledge the convergence of the series
sub agm( $a is copy, $g is copy ) {
($a, $g) = ($a + $g)/2, sqrt $a * $g
until $a ~~ $g;
return $a;
}
say agm 1, 1/sqrt 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment