[Jprogramming] Recursive programming (and scoping therein)

Aai agroeneveld400 at gmail.com
Mon Feb 11 14:35:07 UTC 2013


>
> Essentially what I am looking for here is all the possible combinations of
> the prime factors.

In this case I wouldn't use recursion. Instead use e.g. powerset:

poset=:  (],,&.>)/@(<@,:"_1,a:"_)    (see also: 
http://www.jsoftware.com/jwiki/Essays/Power%20Set )

    ~. poset q: 60
┌┬─┬─┬───┬─┬───┬───┬─────┬───┬─────┬─────┬───────┐
││5│3│3 5│2│2 5│2 3│2 3 5│2 2│2 2 5│2 2 3│2 2 3 5│
└┴─┴─┴───┴─┴───┴───┴─────┴───┴─────┴─────┴───────┘

If you mean divisors have a look at

http://www.jsoftware.com/jwiki/Essays/Divisors

    div 60
1 2 3 4 5 6 10 12 15 20 30 60


or with poset

    /:~ */&> ~. poset q: 60
1 2 3 4 5 6 10 12 15 20 30 60


-- 
Met vriendelijke groet,
@@i = Arie Groeneveld



More information about the Programming mailing list