On Mon, Jun 8, 2009 at 9:00 AM, Raul Miller<[email protected]> wrote: > On Mon, Jun 8, 2009 at 8:53 AM, Mike Day<[email protected]> wrote: >> So it looks as if Raul's function needs a bit of extra filtering to > > Oops, thank you! > > pp=: *./@(1...@~., 2&<:, 0&<@#)@(#/....@q: ::0:"0) > > (And extra filtering will not make mine faster).
No, I still have a problem... pp 144 0 (#/....@q: ::0:"0) 144 4 2 I have a problem with composite numbers which themselves contain repeated primes. Here's my first attempt at fixing this issue: pp=: *./@(0&<@#, 2&<:, 0= <./ | ])@(#/....@q:) ::0:"0 However: (pp -: pp1) i. 10000 0 I. (pp ~: pp1) i. 10000 5184 pp 5184 0 So... I need to think about this issue. I have mapped integers into the domain of the counts of their prime factors, and I must determine from those counts of prime factors whether or not a number is a power of some product of those primes. This means that the counts share a common divisor other than one. In other words: pp0=: *./@(0&<@#, 2&<:, 1 < +./)@(#/....@q: ::0:"0) (pp0 -: pp1) i. 100000 1 But correctness is much more important than efficiency, and I quite a bit to Mike Day for getting this one right. FYI, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
