this is very simple and maybe fast (0 1 ,: 1 1)&(+/ . *) ^:(i.12) 0 1 0 1 1 1 1 2 2 3 3 5 5 8 8 13 13 21 21 34 34 55 55 89 89 144
[email protected] M.Shimura > 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,~,.@|....@#:) > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
