Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Mertens-function/Arturo/mertens-function.arturo
Normal file
25
Task/Mertens-function/Arturo/mertens-function.arturo
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
mobius: function [n][
|
||||
if n=0 -> return ""
|
||||
if n=1 -> return 1
|
||||
f: factors.prime n
|
||||
|
||||
if f <> unique f -> return 0
|
||||
if? odd? size f -> return neg 1
|
||||
else -> return 1
|
||||
]
|
||||
|
||||
mertens: function [z][sum map 1..z => mobius]
|
||||
|
||||
print "The first 99 Mertens numbers are:"
|
||||
loop split.every:20 [""]++map 1..99 => mertens 'a [
|
||||
print map a 'item -> pad to :string item 2
|
||||
]
|
||||
|
||||
print ""
|
||||
|
||||
mertens1000: map 1..1000 => mertens
|
||||
print ["Times M(x) is zero between 1 and 1000:" size select mertens1000 => zero?]
|
||||
|
||||
crossed: new 0
|
||||
fold mertens1000 [a,b][if and? zero? b not? zero? a -> inc 'crossed, b]
|
||||
print ["Times M(x) crosses zero between 1 and 1000:" crossed]
|
||||
Loading…
Add table
Add a link
Reference in a new issue