Stern-Brocot sequence: Difference between revisions
Added Quackery.
m (Fix terminal condition error (stopped at 999 instead of 1000).) |
(Added Quackery.) |
||
Line 5,113:
[(100, 1179)]
True</pre>
=={{header|Quackery}}==
<lang Quackery> [ [ dup while
tuck mod again ]
drop abs ] is gcd ( n n --> n )
[ 2dup peek
dip [ 1+ 2dup peek ]
over + swap join
swap dip join ] is two-terms ( [ n --> [ n )
' [ 1 1 ] 0
8 times two-terms
over 15 split drop
witheach [ echo sp ] cr
[ two-terms
over -2 peek 100 = until ]
drop
10 times
[ i^ 1+ over find 1+ echo sp ] cr
dup size 1 - echo cr
false swap
behead swap witheach
[ tuck gcd 1 != if
[ dip not conclude ] ]
drop iff
[ say "Reducible pair found." ]
else
[ say "No reducible pairs found." ]</lang>
{{out}}
<pre>1 1 2 1 3 2 3 1 4 3 5 2 5 3 4
1 3 5 9 11 33 19 21 35 39
1179
No reducible pairs found.
</pre>
=={{header|R}}==
|