Inspired by Haskells: http://tinyurl.com/3c3yor


ffib=:(+&*:,]*]-~+:@[)/@]`((+&*:,~[*[++:@])/@])@.({...@[)/@(1x 0,~,.@|....@#:)

   ffib"0 i.8
 1  0
 1  1
 2  1
 3  2
 5  3
 8  5
13  8
21 13

   ts '{: ffib 100001'
0.748854 265536

   11{. ": {: ffib 100001
42026927029


(slower) variants:

ffib2=: (+&*:,+:@*-*:@])/@]`((+&*:,~*:@[++:@*)/@])@.({...@[)/@(1x 
0,~,.@|....@#:)

ffib3=: (,+/ .*~,,:],-)/@]`(((,~,:~[,+)+/ .*,~)/@])@.({...@[)/@(1x
0,~,.@|....@#:)




=@@i



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

Reply via email to