Hi all!
A simple recursive definition of the problem to find all k-sets in a set
of n items.
S=: 4 : 0
NB.log=:,.<i.0
if. x=1 do.
r=.,.i.y
else.
r=.0 0$0
if. y>:x do.
for_i. (<:x)+i.>:y-x do.
NB.log=:log,<i;y
v=.(x-1) S i
NB.log=:log,<v
r=.r, v ,. i
NB.log=:log,<r
end.
end.
end.
r
)
Cheers,
Erling Hellenäs
On 2017-11-03 18:16, Linda Alvord wrote:
It seems that you mighg want to use a diferent name for your combE
load 'stats'
(3 comb 4);3 combE 4
┌─────┬───────┐
│0 1 2│0 0 0 1│
│0 1 3│0 0 0 2│
│0 2 3│0 0 1 1│
│1 2 3│0 0 1 2│
│ │0 0 2 1│
│ │0 0 2 2│
│ │0 1 0 1│
│ │0 1 0 2│
│ │0 1 1 1│
│ │0 1 1 2│
│ │0 1 2 1│
│ │0 1 2 2│
│ │0 2 0 1│
│ │0 2 0 2│
│ │0 2 1 1│
│ │0 2 1 2│
│ │0 2 2 1│
│ │0 2 2 2│
│ │1 0 0 1│
│ │1 0 0 2│
│ │1 0 1 1│
│ │1 0 1 2│
│ │1 0 2 1│
│ │1 0 2 2│
│ │1 1 0 1│
│ │1 1 0 2│
│ │1 1 1 1│
│ │1 1 1 2│
│ │1 1 2 1│
│ │1 1 2 2│
│ │1 2 0 1│
│ │1 2 0 2│
│ │1 2 1 1│
│ │1 2 1 2│
│ │1 2 2 1│
│ │1 2 2 2│
└─────┴───────┘
Linda
-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf
Of Erling Hellenäs
Sent: Friday, November 3, 2017 12:44 PM
To: [email protected]
Subject: Re: [Jprogramming] Partitions
Hi all!
I did not correctly understand the e. verb
24 e. r4
0
24 e. ,r4
1
So 358358 surely was there and was double-counted.
Cheers,
Erling Hellenäs
On 2017-11-03 17:07, Erling Hellenäs wrote:
No, its not. It seems it should have bin there. Maybe something is
wrong. /Erling
On 2017-11-03 16:56, Erling Hellenäs wrote:
Lol. This root is double-counted. 1 1 1 1 358358 /Erling
On 2017-11-03 16:42, Erling Hellenäs wrote:
Hi all!
My take:
v=:1 1 1 1 2 7 11 13 179
r=:5 parRuskeyE 9
r2=: >r (*/)@:{&.>"1 0 < v
r3=:/:~"1 r2
r4=: ~.r3
NB. One root is 1 1 1 1 358358
NB. All permutations
(!5)*1+#r4
6360
Cheers,
Erling Hellenäs
On 2017-11-03 15:03, Erling Hellenäs wrote:
Sorry. Add ones. /Erling
On 2017-11-03 15:00, Erling Hellenäs wrote:
OK. The five prime factors are needed if you want to multiply 5
numbers and get 358358, except that you can possibly add zeros and
358358 itself? /Erling
On 2017-11-03 14:35, 'Mike Day' via Programming wrote:
Language differences?
Personally, I tend to be rather careless, using the terms
“factor” and “divisor” for the same thing, when “divisor” is
perhaps to be preferred. However, Pari GP provides a library
function “factor” to deliver the prime factorisation of its
argument, in a similar fashion to J’s q: .
So, strictly speaking, perhaps, the factors of 358358 are 2 7
11 13 179 and its divisors are 1 2 7 11 13 14 22 etc...
You’re both right!
Mike
Please reply to [email protected].
Sent from my iPad
On 3 Nov 2017, at 11:25, Erling Hellenäs
<[email protected]> wrote:
Hi all!
Raul:
"Hmm... actually, thinking about it, the par approach here is
not efficient enough for this example. 5 parRuskeyE 32 is too
big of a result, I think. (358358 has 5 distinct prime factors
and, thus, 32 integer factors.)"
However there are only 5 integer factors:
q: 358358
2 7 11 13 179
*/q:358358
358358
Now you ask me for 44 5 integer factorizations.
As far as I understand there is only one 5 integer factorization
of 358358 unless you count 1 and 358358 as factors.
In any case it can be handled by parRuskeyE.
Cheers,
Erling Hellenäs
Den 2017-11-03 kl. 10:58, skrev Raul Miller:
I'm not sure where you showed the 44 different 5 integer
factorizations of 358358?
Thanks,
----------------------------------------------------------------
------
For information about J forums see
http://www.jsoftware.com/forums.htm
-----------------------------------------------------------------
-----
For information about J forums see
http://www.jsoftware.com/forums.htm
------------------------------------------------------------------
----
For information about J forums see
http://www.jsoftware.com/forums.htm
-------------------------------------------------------------------
--- For information about J forums see
http://www.jsoftware.com/forums.htm
--------------------------------------------------------------------
-- For information about J forums see
http://www.jsoftware.com/forums.htm
---------------------------------------------------------------------
- For information about J forums see
http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm