How to resolve the algorithm Meissel–Mertens constant step by step in the Arturo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Meissel–Mertens constant step by step in the Arturo programming language
Table of Contents
Problem Statement
Calculate Meissel–Mertens constant up to a precision your language can handle.
Analogous to Euler's constant, which is important in determining the sum of reciprocal natural numbers, Meissel-Mertens' constant is important in calculating the sum of reciprocal primes.
We consider the finite sum of reciprocal natural numbers: 1 + 1/2 + 1/3 + 1/4 + 1/5 ... 1/n this sum can be well approximated with: log(n) + E where E denotes Euler's constant: 0.57721... log(n) denotes the natural logarithm of n.
Now consider the finite sum of reciprocal primes: 1/2 + 1/3 + 1/5 + 1/7 + 1/11 ... 1/p this sum can be well approximated with: log( log(p) ) + M where M denotes Meissel-Mertens constant: 0.26149...
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Meissel–Mertens constant step by step in the Arturo programming language
Source code in the arturo programming language
meisselMertens: function [depth][
Euler: 0.57721566490153286
m: (1//2) + ln 1-1//2
loop range.step:2 3 depth 'x ->
if prime? x ->
m: m + (1//x) + ln 1-1//x
return m + Euler
]
print meisselMertens 10000000
You may also check:How to resolve the algorithm FizzBuzz step by step in the bc programming language
You may also check:How to resolve the algorithm Filter step by step in the Octave programming language
You may also check:How to resolve the algorithm Factorial primes step by step in the J programming language
You may also check:How to resolve the algorithm 100 prisoners step by step in the Transact-SQL programming language
You may also check:How to resolve the algorithm Index finite lists of positive integers step by step in the 11l programming language