Skip to content

Instantly share code, notes, and snippets.

@stmuk
Created November 11, 2015 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stmuk/074811935f16a6725f76 to your computer and use it in GitHub Desktop.
Save stmuk/074811935f16a6725f76 to your computer and use it in GitHub Desktop.
# pi_sequential_iteration.rb port
use v6;
#my $n = 100000;
my int $n = 100000;
my $delta = 1.0 / $n;
my $sum = 0.0;
#my $i = 1;
my int $i = 1;
while ( $i <= $n) {
my $x = ( $i - 0.5 ) * $delta;
$sum += 1.0 / ( 1.0 + $x * $x );
$i += 1;
}
my $pi = 4.0 * $delta * $sum;
say $pi;
# vim: set ft=perl6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment