Likewise: pffact=:([: +/ ] <.@% [ ^ 1 + [: i. <.@^.) P=:9+1e9 pw=.1e9 pffact">~ pr=.p:i.240 1 p: P 1 datatype P integer mul=.1+pr (P&|@^) 2 (P&|@*) pw datatype mul integer P&|@*/ mul 39355325
JVERSION Engine: j803/2014-10-19-11:11:11 Library: 8.04.06 Qt IDE: 1.4.3/5.4.2 Platform: Darwin 64 Installer: J804 install InstallPath: /applications/j64-804 -- Raul On Fri, Jul 31, 2015 at 12:24 PM, Jon Hough <[email protected]> wrote: > Hmm... I tried it and I got > P&|@*/ mul > > 346052331 > > > > > >> From: [email protected] >> To: [email protected] >> Date: Fri, 31 Jul 2015 12:16:20 -0400 >> Subject: [Jprogramming] multiplication bug >> >> i am trying to multiply several integers modulo small prime number here and >> fail at that. >> >> ------------------------ >> >> NB. highest power of prime x that divides !y >> >> pffact=:([: +/ ] <.@% [ ^ 1 + [: i. <.@^.) >> >> P=:9+1e9 >> >> pw=.1e9 pffact">~ pr=.p:i.240 NB. first few primes and their powers >> >> 1 p: P NB. P is prime >> >> 1 >> datatype P >> integer >> >> ------------------------ >> here is a list of integers I am trying to multiply >> ------------------------ >> >> mul=.1+pr (P&|@^) 2 (P&|@*) pw >> datatype mul >> integer >> >> ------------------------ >> And here is what happens when I actually multiply them: >> ------------------------ >> >> P&|@*/ mul >> 0 >> >> ------------------------ >> which is not the right answer >> ------------------------ >> >> P&|@*/ |.mul >> 3.90562e7 >> >> ------------------------ >> >> >> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
