niklas-heer / speed-comparison

A repo which compares the speed of different programming languages.
https://niklas-heer.github.io/speed-comparison
MIT License
475 stars 76 forks source link

Perl version? #3

Closed cpp-monster closed 1 year ago

cpp-monster commented 5 years ago

Would you add perl to the comparison?

#!/usr/bin/env perl                                                                                                                                                      
use strict;

open(my $fh, "<rounds.txt") or die "$!";
my $rounds = <$fh> || die "$!";

my $x = 1.0;
my $pi = 1.0;

for my $i (2..$rounds+2) {
    $x *= -1.0;
    $pi += $x / (2 * $i - 1);
}

$pi *= 4;

printf("%.17g", $pi);
niklas-heer commented 5 years ago

Hi @cpp-monster thank you for your suggestion.

I'm sorry to say that I'm currently not focusing on the project so I don't plan to extend the scope, but I'm open to pull requests. 🙂