36 lines
825 B
Plaintext
36 lines
825 B
Plaintext
mertens: procedure options(main);
|
|
%replace MAX by 1000;
|
|
|
|
declare M(1:MAX) fixed binary(5);
|
|
declare (n, k) fixed binary(10);
|
|
declare (isZero, crossZero) fixed binary(8);
|
|
|
|
M(1) = 1;
|
|
do n = 2 to MAX;
|
|
M(n) = 1;
|
|
do k = 2 to n;
|
|
M(n) = M(n) - M(divide(n,k,10));
|
|
end;
|
|
end;
|
|
|
|
put skip list('The first 99 Mertens numbers are:');
|
|
put skip list(' ');
|
|
do n = 1 to 99;
|
|
put edit(M(n)) (F(3));
|
|
if mod(n,10) = 9 then put skip;
|
|
end;
|
|
|
|
isZero = 0;
|
|
crossZero = 0;
|
|
do n = 2 to MAX;
|
|
if M(n) = 0 then do;
|
|
isZero = isZero + 1;
|
|
if M(n-1) ^= 0 then
|
|
crossZero = crossZero + 1;
|
|
end;
|
|
end;
|
|
|
|
put skip list('Zeroes: ',isZero);
|
|
put skip list('Crossings:',crossZero);
|
|
end mertens;
|