RosettaCodeData/Task/Mertens-function/BCPL/mertens-function.bcpl

37 lines
739 B
Plaintext

get "libhdr"
manifest $( limit = 1000 $)
let mertens(v, max) be
$( v!1 := 1
for n = 2 to max do
$( v!n := 1
for k = 2 to n do
v!n := v!n - v!(n/k)
$)
$)
let start() be
$( let m = vec limit
let eqz, crossz = 0, 0
writes("The first 99 Mertens numbers are:*N")
mertens(m, limit)
for y=0 to 90 by 10 do
$( for x=0 to 9 do
test x+y=0
then writes(" ")
else writed(m!(x+y),3)
wrch('*N')
$)
for x=2 to limit do
if m!x=0 then
$( eqz := eqz + 1
unless m!(x-1)=0 do crossz := crossz + 1
$)
writef("M(N) is zero %N times.*N", eqz)
writef("M(N) crosses zero %N times.*N", crossz)
$)