Meissel–Mertens constant: Difference between revisions

Removed duplicate entry and fixed syntax highlighting.
(Added Wren)
(Removed duplicate entry and fixed syntax highlighting.)
Line 65:
{{libheader|Wren-fmt}}
Wren's only native number type is a 64 bit float (15 or 16 digits accuracy) and it appears from the following results that, no matter how many primes we use, we're not going to be able to improve on 8 digit accuracy for M with this particular number type.
<langsyntaxhighlight lang="ecmascript">import "./math" for Int
import "./fmt" for Fmt
 
Line 80:
c = c + 1
if ((c % 1e7) == 0 || c == pc) Fmt.print("$,11d $0.12f", c, sum + euler)
}</langsyntaxhighlight>
 
{{out}}
<pre>
Primes added M
------------ --------------
10,000,000 0.261497213008
20,000,000 0.261497213008
30,000,000 0.261497213009
40,000,000 0.261497213008
50,000,000 0.261497213009
60,000,000 0.261497213009
70,000,000 0.261497213009
80,000,000 0.261497213009
90,000,000 0.261497213009
100,000,000 0.261497213009
105,097,565 0.261497213009
</pre>
 
=={{header|Wren}}==
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
Wren's only native number type is a 64 bit float (15 or 16 digits accuracy) and it appears from the following results that, no matter how many primes we sieve for, we're not going to be able to improve on 8 digit accuracy for M with this particular number type.
<lang ecmascript>import "./math" for Int
import "./fmt" for Fmt
 
var euler = 0.57721566490153286
var primes = Int.primeSieve(2.pow(31))
var pc = primes.count
var sum = 0
var c = 0
System.print("Primes added M")
System.print("------------ --------------")
for (p in primes) {
var rp = 1/p
sum = sum + (1-rp).log + rp
c = c + 1
if ((c % 1e7) == 0 || c == pc) Fmt.print("$,11d $0.12f", c, sum + euler)
}</lang>
 
{{out}}
9,482

edits