[Jprogramming] multiplication bug

Andrew Nikitin nsg21 at hotmail.com
Fri Jul 31 16:16:20 UTC 2015


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

------------------------ 


 		 	   		  


More information about the Programming mailing list