Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
51
Task/Mertens-function/Forth/mertens-function.fth
Normal file
51
Task/Mertens-function/Forth/mertens-function.fth
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
: AMOUNT 1000 ;
|
||||
|
||||
variable mertens AMOUNT cells allot
|
||||
: M 1- cells mertens + ; \ 1-indexed array
|
||||
|
||||
: make-mertens
|
||||
1 1 M !
|
||||
2 begin dup AMOUNT <= while
|
||||
1 over M !
|
||||
2 begin over over >= while
|
||||
over over / M @
|
||||
2 pick M @ swap -
|
||||
2 pick M !
|
||||
1+ repeat
|
||||
drop
|
||||
1+ repeat
|
||||
drop
|
||||
;
|
||||
|
||||
: print-row
|
||||
begin dup while
|
||||
swap dup M @ 3 .r 1+
|
||||
swap 1-
|
||||
repeat
|
||||
drop
|
||||
;
|
||||
|
||||
: print-table ." "
|
||||
1 9 print-row cr
|
||||
begin dup 100 < while 10 print-row cr repeat
|
||||
drop
|
||||
;
|
||||
|
||||
: find-zero-cross
|
||||
0 0
|
||||
1 begin dup AMOUNT <= while
|
||||
dup M @ 0= if
|
||||
swap 1+ swap
|
||||
dup 1- M @ 0<> if rot 1+ -rot then
|
||||
then
|
||||
1+
|
||||
repeat
|
||||
drop
|
||||
;
|
||||
|
||||
make-mertens
|
||||
." The first 99 Mertens numbers are:" cr print-table
|
||||
find-zero-cross
|
||||
." M(N) is zero " . ." times." cr
|
||||
." M(N) crosses zero " . ." times." cr
|
||||
bye
|
||||
Loading…
Add table
Add a link
Reference in a new issue