Calkin-Wilf sequence: Difference between revisions

Added Quackery.
(Added Forth entry)
(Added Quackery.)
Line 1,861:
 
83116/51639 is the 123_456_789'th term.</pre>
 
=={{header|Quackery}}==
 
<lang Quackery> [ $ "bigrat.qky" loadfile ] now!
 
[ ' [ [ 1 1 ] ]
swap 1 - times
[ dup -1 peek do
2dup proper 2drop
2 * n->v
2swap -v 1 n->v v+ v+
1/v join nested join ] ] is calkin-wilf ( n --> [ )
 
[ 1 & ] is odd ( n --> b )
 
[ [] unrot
[ proper
2swap join unrot
over 0 != while
1/v again ]
2drop ] is cf ( n/d --> [ )
 
[ dup size odd not if
[ -1 split do
1 - join
1 join ] ] is oddcf ( [ --> [ )
 
[ 0 swap
reverse witheach
[ i odd iff
<< done
dup dip <<
bit 1 - | ] ] is rl->n ( [ --> n )
 
[ cf oddcf rl->n ] is cw-term ( n/d --> n )
 
20 calkin-wilf
witheach
[ do vulgar$ echo$ sp ]
cr cr
83116 51639 cw-term echo</lang>
 
{{out}}
 
<pre>1/1 1/2 2/1 1/3 3/2 2/3 3/1 1/4 4/3 3/5 5/2 2/5 5/3 3/4 4/1 1/5 5/4 4/7 7/3 3/8
 
123456789</pre>
 
=={{header|Raku}}==
1,493

edits