Mertens function: Difference between revisions

Added Quackery.
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(Added Quackery.)
Line 3,223:
M(N) equals zero 92 times.
M(N) crosses zero 59 times.</pre>
 
=={{header|Quackery}}==
 
<code>mobius</code> is defined at [[Möbius function#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ ' [ 0 ]
swap 1+ times
[ dup -1 peek
i^ 1+ mobius
+ join ]
behead drop ] is mertens ( n --> [ )
 
[ 0 swap
witheach
[ 0 = + ] ] is zeroes ( [ --> n )
 
[ 0 0
rot witheach
[ dup 0 =
rot 0 !=
and
rot + swap ]
drop ] is crossings ( [ --> n )
 
[ say " "
99 times
[ dup i^ peek
dup dup
-1 > if sp
abs 10 < if sp
echo
i^ 1+ 10 mod
9 = if cr ]
drop ] is grid ( [ --> )
 
1000 mertens
say "First 99 terms:"
cr
dup grid
cr
dup zeroes echo say " zeroes and "
crossings echo say " crossings"</syntaxhighlight>
 
{{out}}
 
<pre>First 99 terms:
1 0 -1 -1 -2 -1 -2 -2 -2
-1 -2 -2 -3 -2 -1 -1 -2 -2 -3
-3 -2 -1 -2 -2 -2 -1 -1 -1 -2
-3 -4 -4 -3 -2 -1 -1 -2 -1 0
0 -1 -2 -3 -3 -3 -2 -3 -3 -3
-3 -2 -2 -3 -3 -2 -2 -1 0 -1
-1 -2 -1 -1 -1 0 -1 -2 -2 -1
-2 -3 -3 -4 -3 -3 -3 -2 -3 -4
-4 -4 -3 -4 -4 -3 -2 -1 -1 -2
-2 -1 -1 0 1 2 2 1 1 1
 
92 zeroes and 59 crossings</pre>
 
=={{header|Raku}}==
1,462

edits