Because of a hidden order it's possible to generate the sequence [1]
much faster then e.g. by
(, ] (({~<:)+({~-)) {:)^:(_2+2^5) 1 1
1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 10 11 12 12 13 14 14 15 15 15 16 16 16
16 16
with the following method:
1 1,(#2...@#);(,<@;@(|.@(#;. 1) (],~1$~[)&.> <@:>:;.1 )@>@{:)^:(3) <2
1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 10 11 12 12 13 14 14 15 15 15 16 16 16
16 16
ts '1 1,(#2...@#);(,<@;@(|.@(#;. 1) (],~1$~[)&.> <@:>:;.1
)@>@{:)^:(16-2) <2'
0.026618 1840448
ts '(, ] (({~<:)+({~-)) {:)^:(_2+2^16) 1 1'
2.17943 1051584
HCF=.1 1,(#2...@#);(,<@;@(|.@(#;. 1) (],~1$~[)&.> <@:>:;.1
)@>@{:)^:(16-2) <2
HC=. (, ] (({~<:)+({~-)) {:)^:(_2+2^16) 1 1
HC-:HCF
1
[1] http://rosettacode.org/wiki/Hofstadter-Conway_$10,000_sequence
--
Met vriendelijke groet,
=@@i
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm