Representing a permutation, and a curiosity

In summary, the conversation discusses a program that encodes permutations into a single integer number, using a series of indexes and factorials. The greatest index, n! - 1, is represented as 4.4! + 3.3! + 2.2! + 1.1!, and the question is raised on how to prove that sum(i!.i) = n! - 1. The solution is given through induction and the conversation ends with a reference to a similar problem in the 1969 Canadian mathematical olympiad.
  • #1
dodo
697
2
I was recently writing a program that needed to encode a permutation
into a single integer number (an index, from 0 to n! - 1).

The program transformed the permutation (f.i., of 5 numbers) into
a "series of indexes", in the ranges [0..4], [0..3], [0..2], [0..1],
4 indexes in total (one less than the permutation size, since
the last member of the permutation is totally dependent on the choices
of the previous members, and thus need not to be represented).

The first index directly represents the first number;
the second index is the *relative position* of the second number,
in the set where the first was removed from 1..5 (the "remaining numbers");
the third index is the position in the set 1..5 with first and second
removed, and so on. (That's why the indexes' range gets smaller
for each new "digit".) Then the digits are multiplied by factorials,
in order to assemble the final number:
[0..4].4! + [0..3].3! + [0..2].2! + [0..1].1!

(The factorials come the same way as you'd assemble a Horner-form
polynomial, only with "x" increasing from 1 to n-1 for each coefficient;
so you get factorials instead of powers of x.)

This produces a nice sequence of indexes from 0 to n! - 1, from all
permutations (1,2,3,4,5), (1,2,3,5,4), ... (5,4,3,2,1).

What striked me was the fact that the greatest index, n! - 1,
was represented as 4.4! + 3.3! + 2.2! + 1.1!.

How in heaven would you prove that sum(i!.i) = n! - 1 ??
(Edit: sum for i=1..n-1. Sorry for my pig-latex.)

(hey! programmer here! - if you had an homomorphism mapping people to
math knowledge, you'd call its kernel "computer programmers" :P )
 
Last edited:
Physics news on Phys.org
  • #2
By induction.

1*1! + ... + n*n = (n + 1)! - 1 (I don't enjoy summing things up to n - 1) is true for n = 1. Suppose it's true for n. Then

1*1! + ... + n*n! + (n + 1)(n + 1)! = (n + 1)! - 1 + (n + 1)(n + 1)! = (n + 1)!(1 + n + 1) - 1 = (n + 1)!(n + 2) - 1 = (n + 2)! - 1, as required.

QED.
 
  • #3
Shame on me! It was rather simple. Thank you!
 
  • #4
I knew I'd seen this problem before, and indeed, it was in the 1969 Canadian mathematical olympiad ;) http://www.kalva.demon.co.uk/canada/can69.html
 
Last edited by a moderator:
  • #5
Oh well... it's harder if you're not given both sides of the equation, of course. :D
 

What is a permutation?

A permutation is a way of arranging a set of objects or elements in a specific order. It is essentially a rearrangement of the elements, where each element appears only once in the sequence.

How do you represent a permutation?

A permutation can be represented in various ways, such as using a notation, a matrix, a cycle, or a visual diagram. The most common notation used is the one-line notation, where the elements are listed in the desired order separated by commas, e.g. (1, 2, 3, 4).

What is the difference between a permutation and a combination?

A permutation is an arrangement of a set of elements in a specific order, while a combination is a selection of elements from a set without considering the order. In other words, a permutation focuses on the order of the elements, while a combination does not.

What is the significance of permutations in mathematics?

Permutations are essential in various areas of mathematics, such as combinatorics, group theory, and probability. They are used to solve problems related to counting, arrangements, and symmetries, and have applications in fields like computer science, physics, and genetics.

Is there a limit to the number of permutations that can be formed from a set of elements?

Yes, the number of permutations that can be formed from a set of n elements is n!, which is known as the factorial of n. For example, a set of 3 elements can have 3! = 6 permutations (123, 132, 213, 231, 312, 321).

Similar threads

  • Linear and Abstract Algebra
Replies
15
Views
4K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
34
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
600
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
1K
  • Linear and Abstract Algebra
Replies
2
Views
959
  • Linear and Abstract Algebra
Replies
2
Views
791
  • Programming and Computer Science
Replies
22
Views
758
  • General Math
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
6
Views
1K
Back
Top