Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Yellowstone-sequence/Forth/yellowstone-sequence.fth
Normal file
17
Task/Yellowstone-sequence/Forth/yellowstone-sequence.fth
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
: array create cells allot ;
|
||||
: th cells + ; \ some helper words
|
||||
|
||||
30 constant #yellow \ number of yellowstones
|
||||
|
||||
#yellow array y \ create array
|
||||
( n1 n2 -- n3)
|
||||
: gcd dup if tuck mod recurse exit then drop ;
|
||||
: init 3 0 do i 1+ y i th ! loop ; ( --)
|
||||
: show cr #yellow 0 do y i th ? loop ; ( --)
|
||||
: gcd-y[] - cells y + @ over gcd ; ( k i n -- k gcd )
|
||||
: loop1 begin 1+ over 2 gcd-y[] 1 = >r over 1 gcd-y[] 1 > r> or 0= until ;
|
||||
: loop2 over true swap 0 ?do over y i th @ = if 0= leave then loop ;
|
||||
: yellow #yellow 3 do i 3 begin loop1 loop2 until y rot th ! loop ;
|
||||
: main init yellow show ;
|
||||
|
||||
main
|
||||
Loading…
Add table
Add a link
Reference in a new issue