The creative insight, supplied by the perl programmer at rosettacode, shows that the number must be divisible by the least common multiple of the digits.  This shrinks the search space.

   NB. 16bfedcba987654321 loses precision and so we need to work in extended data type

   HEX_DIGITS =: >: i. _15x
   LCM =: *./ HEX_DIGITS
   START =: <.&.(%&LCM)16#.HEX_DIGITS
   Until =: conjunction def 'u^:(0-:v)^:_'
   test=: 0 -.@e. HEX_DIGITS e. 16&#.inv
   [SOLUTION =: -&LCM Until test START
1147797065081426760

   '16b' , (16 #.inv SOLUTION) { Num_j_ , 26 }. Alpha_j_
16bfedcb59726a1348

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

Reply via email to