Correction to make the last assert work correctly:

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

It shouldn't be:

   nthHam 31
1

but:

   nthHam 31
|assertion failure: nthHam
|   c<#}.z


Anyway, if you dare using it, use nthHam for N>:50000

-- 
Met vriendelijke groet,
=@@i

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

Reply via email to