I appear to have solved PE 159,  & have even found the verb that seemed to do 
the work,  but have forgotten how it works!  

Anyway,  it might be worth considering a constructive approach,  whereby you 
consider possible combinations of primes generating all numbers in the domain 
rather than analysing loads of composite numbers. Not a spoiler,  as I don't 
know offhand whether it applies here!

Personally,  I'm stuck on PE 592,  among many others,  which is why I needed 
help with modular multiplication of largish numbers recently...

Mike

Please reply to [email protected].      
Sent from my iPad

> On 10 May 2017, at 15:12, David Lambert <[email protected]> wrote:
> 
> I need a fast algorithm to find all factorizations of a number. This method 
> is terribly redundant, let's say the prime factors are 2^19 .  And the method 
> is get the nub of the product of all complete partitions of all the 
> permutations of the prime factors.
> 
>   boxdraw_j_ 1
> 
>   permutations=: A.&i.~ !
> 
>   unique_permutations=: ~.@:({~ permutations@:#)
> 
>   unique_permutations 'aab'
> aab
> aba
> baa
>   unique_permutations q:24
> 2 2 2 3
> 2 2 3 2
> 2 3 2 2
> 3 2 2 2
> 
> 
>   complete_partitions=: <;.1"_ 1~ (1 ,. [: #: [: i. 2 ^ [: <: [: # {.)
> 
>   complete_partitions ,:'abc'
> +---+--+-+
> |abc|  | |
> +---+--+-+
> |ab |c | |
> +---+--+-+
> |a  |bc| |
> +---+--+-+
> |a  |b |c|
> +---+--+-+
> 
>   ([: < [: /:~ -.&1)"1 */&> complete_partitions unique_permutations q:24
> +--+----+---+-----+----+-----+-----+-------+
> |24|3 8 |4 6|2 3 4|2 12|2 3 4|2 2 6|2 2 2 3|
> +--+----+---+-----+----+-----+-----+-------+
> |24|2 12|4 6|2 3 4|2 12|2 2 6|2 2 6|2 2 2 3|
> +--+----+---+-----+----+-----+-----+-------+
> |24|2 12|4 6|2 2 6|2 12|2 2 6|2 3 4|2 2 2 3|
> +--+----+---+-----+----+-----+-----+-------+
> |24|2 12|4 6|2 2 6|3 8 |2 3 4|2 3 4|2 2 2 3|
> +--+----+---+-----+----+-----+-----+-------+
> 
>   NB. multiplication commutes, allowing simplification
>   ,. ([: ~. [: , ([: < [: /:~ -.&1)"1) */&> complete_partitions 
> unique_permutations q:24
> +-------+
> |24     |
> +-------+
> |3 8    |
> +-------+
> |4 6    |
> +-------+
> |2 3 4  |
> +-------+
> |2 12   |
> +-------+
> |2 2 6  |
> +-------+
> |2 2 2 3|
> +-------+
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to