RosettaCodeData/Task/Mertens-function/11l/mertens-function.11l

26 lines
602 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

F mertens(count)
Generate Mertens numbers
V m = [-1, 1]
L(n) 2 .. count
m.append(1)
L(k) 2 .. n
m[n] -= m[n I/ k]
R m
V ms = mertens(1000)
print(The first 99 Mertens numbers are:)
print( , end' )
V col = 1
L(n) ms[1.<100]
print(#2.format(n), end' )
col++
I col == 10
print()
col = 0
V zeroes = sum(ms.map(x -> Int(x == 0)))
V crosses = sum(zip(ms, ms[1..]).map((a, b) -> Int(a != 0 & b == 0)))
print(M(N) equals zero #. times..format(zeroes))
print(M(N) crosses zero #. times..format(crosses))