Recently I was looking at how I might generate something that look like an
encryption key and noticed this oddity:

   #val=. '0123456789ABCDEF'
16
   val{~(#val)|2^~p:i.128
49919919191919199991119119199119199199199911919199111911919199911991991119919911991119119191199191999991919111191911919991999991

   frtab val{~(#val)|2^~p:i.128
+--+-+
|1 |4|
+--+-+
|68|9|
+--+-+
|59|1|
+--+-+

Where "frtab" is a frequency table generator:

frtab=: 3 : 0
   cts=. #&>y</.y        NB. # unique items...
   if. -.isNum y do.     NB. Special case enclosed, text mat, text vec,
       if. (L.=0:) y do. (<"0 cts),.<"0 ~.y else.
           if. 2=#$y do. (<"0 cts),.<"1 ~.y else. (<"0 cts),.<"0 ~.y end.
       end.
   else. cts,.~.y end.   NB. and simple numeric vec.
NB.EG (1 2 3 2 1,. 11 22 33 222 99) -: frtab 11 22 22 33 33 33 222 222 99
)

Any obvious reason why the 16| of squares of primes should return only "1"
and "9" for this sample?


-- 

Devon McCormick, CFA

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

Reply via email to