Meissel–Mertens constant: Difference between revisions

Content added Content deleted
imported>Maxima enthusiast
No edit summary
(→‎{{header|Perl}}: iterate over primes (much faster))
Line 714: Line 714:
{{libheader|ntheory}}
{{libheader|ntheory}}
<syntaxhighlight lang="perl" line>use v5.36;
<syntaxhighlight lang="perl" line>use v5.36;
use ntheory 'is_prime';
use ntheory qw(forprimes);


my $s;
my $s;
is_prime $_ and $s += log(1 - 1/$_)+1/$_ for 2 .. 10**9;
forprimes { $s += log(1 - 1/$_)+1/$_ } 1e9;
say my $result = $s + .57721566490153286;</syntaxhighlight>
say my $result = $s + .57721566490153286;</syntaxhighlight>
{{out}}
{{out}}