chandra sekaran on Sun, 26 Jun 2016 08:20:07 +0200

 Need permutation help for n!/(n-r)!

• To: pari-users@pari.math.u-bordeaux.fr
• Subject: Need permutation help for n!/(n-r)!
• From: chandra sekaran <sekar.bc@gmail.com>
• Date: Sun, 26 Jun 2016 11:49:59 +0530
• Delivery-date: Sun, 26 Jun 2016 08:20:07 +0200
• Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=5JwwG6vwh7wk1v6pDei3JPtgw5P350omPGwfItbCO7I=; b=YNycxu0DrcrhRjaOXZi1167RGoiJzN6O5p3liCZ+PvPL5gnBIZ5bPkrUzEDUIMhgTY vgh71CquMBOyQR5wGFzQ5sLV74yXSmCIgSuI1zpGVBfMI6InlzAvm6NE0WmvSBKY7ZCH Ezr4DalNfjeO6WLAKD4DXKjvHS5752hH47H4RMA0Pkhc0NehzvH1caS+Dt3U8kRmrEev uIrnISkkjIEdHKwzKaeF/+Wd2MofAHcYN7IB7kJvDew6aZU0UeyiWMHomXNbBtKbFfZC qgMu7IXToSbvIsg+46qheKGT0caeW8hxsVXEvSF4KnBJIHjNNs/sO03IAYIAJTRQX5Qd xF0w==

Hi Joe,

It is working. Thanks.

I want to find out index to number and number to index

with out loop. For small number we can loop through and compare to get the number.

If n and r big number(n=600,r=25) it will take long time to find.

(11:39) gp > 600!/(600-25)!
%59 = 1712444741995872743767068314898968290507882039321992936466415616000000

Is there any efficient algorithm for solving above problem or not.

Thanks,

Chandrasekarn B

---------------------------------------------------

For example if i give the vector [1,4,2] i want to get index number

5 and given the number 5 i want to get the pattern [1,4,2] with out

loop.

n(11:27) gp > n=4
%52 = 4
(11:28) gp > r=3
%53 = 3
(11:28) gp > forvec(v=vector(r,i,[1,n]), if(length(Set(v))==r, print(v)))

Result

1   [1, 2, 3]
2   [1, 2, 4]
3   [1, 3, 2]
4   [1, 3, 4]
5   [1, 4, 2]
6   [1, 4, 3]
7   [2, 1, 3]
8   [2, 1, 4]
9   [2, 3, 1]
10  [2, 3, 4]
11  [2, 4, 1]
12  [2, 4, 3]
13  [3, 1, 2]
14  [3, 1, 4]
15  [3, 2, 1]
16  [3, 2, 4]
17  [3, 4, 1]
18  [3, 4, 2]
19  [4, 1, 2]
20  [4, 1, 3]
21  [4, 2, 1]
22  [4, 2, 3]
23  [4, 3, 1]
24  [4, 3, 2]
-------------------------------------