Meissel–Mertens constant: Difference between revisions

→‎{{header|Wren}}: A change in the order of operations fixed the apparent bug (thanks to Michel Hermier for spotting this).
(→‎J: Define verb)
(→‎{{header|Wren}}: A change in the order of operations fixed the apparent bug (thanks to Michel Hermier for spotting this).)
Line 278:
{{libheader|Wren-math}}
{{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.
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 valid digits for M with this particular number type.
 
However, it's curious that the other examples, which are using (or appear to be using) a 64 bit float type, are able to get much closer to the correct answer. It's clearly something that needs to be investigated.
<syntaxhighlight lang="ecmascript">import "./math" for Int
import "./fmt" for Fmt
Line 293 ⟶ 291:
for (p in primes) {
var rp = 1/p
sum = sum + (1-rp).log + rp + sum
c = c + 1
if ((c % 1e7) == 0 || c == pc) Fmt.print("$,11d $0.12f", c, sum + euler)
Line 302 ⟶ 300:
Primes added M
------------ --------------
10,000,000 0.261497213008261497212987
20,000,000 0.261497213008261497212912
30,000,000 0.261497213009261497212889
40,000,000 0.261497213008261497212878
50,000,000 0.261497213009261497212871
60,000,000 0.261497213009261497212867
70,000,000 0.261497213009261497212864
80,000,000 0.261497213009261497212862
90,000,000 0.261497213009261497212861
100,000,000 0.261497213009261497212859
105,097,565 0.261497213009261497212858
</pre>
9,479

edits