Meissel–Mertens constant: Difference between revisions

Content added Content deleted
(→‎{{header|Perl}}: iterate over primes (much faster))
(Added Sidef)
Line 884: Line 884:
<pre>
<pre>
1: 0.262733140866
1: 0.262733140866
</pre>

=={{header|Sidef}}==
<syntaxhighlight lang="ruby">var sum = 0
1e7.each_prime {|p|
with (1f/p) {|t|
sum += (log(1 - t) + t)
}
}
say sum+Num.EulerGamma</syntaxhighlight>
{{out}}
<pre>
0.26149721577767111119422410228297206467931376306
</pre>
</pre>


Line 891: Line 904:
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
It will be seen that this is converging to the correct answer though we'd need to add a lot more primes to obtain a valid 11th digit.
It will be seen that this is converging to the correct answer though we'd need to add a lot more primes to obtain a valid 11th digit.
<syntaxhighlight lang="ecmascript">import "./math" for Int
<syntaxhighlight lang="wren">import "./math" for Int
import "./fmt" for Fmt
import "./fmt" for Fmt


Line 928: Line 941:
{{libheader|Wren-gmp}}
{{libheader|Wren-gmp}}
This agrees with the Phix entry that the 1,000th digit after the decimal point is '8' after rounding (according to OEIS it's actually '7' but the next one is '7' also).
This agrees with the Phix entry that the 1,000th digit after the decimal point is '8' after rounding (according to OEIS it's actually '7' but the next one is '7' also).
<syntaxhighlight lang="ecmascript">import "./gmp" for Mpf
<syntaxhighlight lang="wren">import "./gmp" for Mpf
import "./math" for Int
import "./math" for Int
import "./fmt" for Fmt
import "./fmt" for Fmt