Ok, I decided to translate the Haskell program from
http://tinyurl.com/yks6mzr
(see end of article)

nthHam=: 3 : 0
 'ln2 ln3 ln5'=. ^. tdv=.2 3 5
 lo=. 0.01 -~ hi=. 1.693-~(*/6,y,ln2, ln3, ln5)^%3
 t=.,:0$0
 for_k. i. 1+ <. hi%ln5 do.
   for_j. i. 1+ <. ln3 %~ hi - p=. k*ln5 do.
     t=. t, j,k,(>.ln2%~lo-q),(<.ln2%~hi-q), q=. p + j * ln3
   end.
 end.
 c=. +/ 1+_2{"1 }. t 
 z=.,:0$0
 for_r. t do.
   for_i. ([+i.@>:@-~)/2{.2}.r do. z=.z, i,(2{.r), ({:r)+i*ln2 end.
 end.
 c=. c - y
 assert. 0 <: c
 assert. c <: # z
 __ q: inv tdv ,: x: 3 {. c { (\: {:"1) }. z
)

   ts 'it=: nthHam 1e6'
0.358981 1314816
   it
519312780448388736089589843750000000000000000000000000000000000000000000000000000000

Any comments/improvements ?

Thnx

-- 
Met vriendelijke groet,
=@@i

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

Reply via email to