Meissel–Mertens constant: Difference between revisions
Added 11l
m (Added the solution to the task in the Wolfram Language) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 38:
:* Details in the Wikipedia article: [https://en.wikipedia.org/wiki/Meissel%E2%80%93Mertens_constant Meissel–Mertens constant]
<br /><br />
=={{header|11l}}==
{{trans|Python}}
<syntaxhighlight lang="11l">
F primes_up_to_limit(Int limit)
[Int] r
I limit >= 2
r.append(2)
V isprime = [1B] * ((limit - 1) I/ 2)
V sieveend = Int(sqrt(limit))
L(i) 0 .< isprime.len
I isprime[i]
Int p = i * 2 + 3
r.append(p)
I i <= sieveend
L(j) ((p * p - 3) >> 1 .< isprime.len).step(p)
isprime[j] = 0B
R r
V euler = 0.57721566490153286
V m = 0.0
L(x) primes_up_to_limit(10'000'000)
m += log(1 - (1 / x)) + (1 / x)
print(‘MM = #.16’.format(euler + m))
</syntaxhighlight>
{{out}}
<pre>
MM = 0.2614972157776471
</pre>
=={{header|ALGOL 68}}==
Line 99 ⟶ 132:
after 1270607 primes, the approximation is: 0.261497214255, last prime considered: 19999999
</pre>
=={{header|BASIC}}==
|