Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
58
Task/Mertens-function/Action-/mertens-function.action
Normal file
58
Task/Mertens-function/Action-/mertens-function.action
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
INCLUDE "D2:PRINTF.ACT" ;from the Action! Tool Kit
|
||||
|
||||
PROC MertensNumbers(INT ARRAY m INT count)
|
||||
INT n,k
|
||||
|
||||
m(1)=1
|
||||
FOR n=2 TO count
|
||||
DO
|
||||
m(n)=1
|
||||
FOR k=2 TO n
|
||||
DO
|
||||
m(n)==-m(n/k)
|
||||
OD
|
||||
OD
|
||||
RETURN
|
||||
|
||||
PROC PrintMertens(INT ARRAY m INT count)
|
||||
CHAR ARRAY s(6)
|
||||
INT i,col
|
||||
|
||||
PrintF("First %I Mertens numbers:%E ",count)
|
||||
col=1
|
||||
FOR i=1 TO count
|
||||
DO
|
||||
StrI(m(i),s)
|
||||
PrintF("%3S",s)
|
||||
col==+1
|
||||
IF col=10 THEN
|
||||
col=0 PutE()
|
||||
FI
|
||||
OD
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
DEFINE MAX="1001"
|
||||
INT ARRAY m(MAX)
|
||||
INT i,zeroCnt=[0],crossCnt=[0],prev=[0]
|
||||
|
||||
Put(125) PutE() ;clear the screen
|
||||
PrintF("Calculation of Mertens numbers,%E please wait...")
|
||||
MertensNumbers(m,MAX)
|
||||
|
||||
Put(125) PutE() ;clear the screen
|
||||
PrintMertens(m,99)
|
||||
|
||||
FOR i=1 TO MAX
|
||||
DO
|
||||
IF m(i)=0 THEN
|
||||
zeroCnt==+1
|
||||
IF prev THEN
|
||||
crossCnt==+1
|
||||
FI
|
||||
FI
|
||||
prev=m(i)
|
||||
OD
|
||||
PrintF("%EM(n) is zero %I times for 1<=n<=%I.%E",zeroCnt,MAX-1)
|
||||
PrintF("%EM(n) crosses zero %I times for 1<=n<=%I.%E",crossCnt,MAX-1)
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue