In http://www.jsoftware.com/pipermail/programming/2007-November/008780.html 
a concise version for the rabbit sequence
http://www.research.att.com/~njas/sequences/A005203 was given:
 (,#;._1)^:(]`1:)

   x:@#.@: ((,#;._1)^:(]`1:))"0 i.9
1 2 5 22 181 5814 1488565 12194330294 25573364166211252


A nice example of repeated squaring is applicable here:

   [:;@|. (;@:{&.><)^:(]`(1 0;~1:))

   #@([:;@|. (;@:{&.><)^:(]`(1 0;~1:)))"0 i.6
3 5 13 89 4181 9227465

   #@((,#;._1)^:(]`1:))"0 [2 3 5 9 17 33
3 5 13 89 4181 9227465

   (([:;@|. (;@:{&.><)^:(]`(1 0;~1:)))5) -: (,#;._1)^:(]`1:)33
1

   5 ts'(,#;._1)^:(]`1:)33'
0.40119768 1.1744294e8

   5 ts'([:;@|. (;@:{&.><)^:(]`(1 0;~1:)))5'
0.085593824 1.1744531e8


R.E. Boss



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to