J4F
Generating Bell numbers based on using
the pierce Triangle.
bell numbers: 1,1,2,5,15,52,203,877,4140,21147,115975
I can come up with these two verbs
NB. for n>21 I need to add ext. precision -- x:&]
bellN=: [:{.([:+/\{:,x:&])^:(]`1:) M.
NB. next pierce triangle row
vp3hr=: 3 : 0
v=.{:y
for_i. i.#y do.
v=. v,(i{v)+i{y
end.
)
bellN1=: [:{.vp3hr^:(]`(x:@1:))
bellN"0 i.10
1 1 2 5 15 52 203 877 4140 21147
bellN1"0 i.10
1 1 2 5 15 52 203 877 4140 21147
(bellN -: bellN1) 100
1
timer 'bellN1 100'
0.086825
timer 'bellN 100' NB. first call
0.305226
Other possibilities?
Regards
=@@i
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm