June 2009
2+mod(Ni,2) is 2 for i in an even length cycle and 3 for i in an odd length cycle. Since 14 is even, there are an even number of elements in odd cycles and an even number of elements in even length cycles. So the product is:
- a multiple of 36 for permutations with mixed odd and even cycles;
- 214 for permutations with even-only cycles; and
- 314 for odd-only cycles.
Since 1299 divides 436-1, the remainder modulo 1299 of 4x depends only on x modulo 36. So
- permutations with mixed odd-even cycles contribute 1;
- permutations with even-only cycles contribute 4**214 = 4**{mod (214,36)} (mod 1299) = 44 (mod 1299) = 256; and
- permutations with odd-only cycles contribute 4**314 = 4**{mod (314,36)} (mod 1299) = 49 (mod 1299) = 1045.
Since the number of permutations with only odd cycles is the same as the number of permutations with only even cycles (Thanks to Vladeta Jovovic for suggesting this equality and to Eytan Sayag for the elegant proof) we have 256+1045 = 2 (mod 1299) from each pair so all together we get the sum of 14! (mod 1299) = 648.
Proving the equivalence between permutation of odd-only cycles and even-only cycles can be shown by writing the first in canonical form (sorting each cycle to start with the biggest element and sorting the cycles by their first element in descending order); then pairing them (if n is even, the number of odd-cycles should be even) and moving the last value from the second cycle of each pair after the last value of the first cycle in the pair. It is easy to show that this transformation is one-to-one from permutation with odd-only cycles to permutation with even-only cycles.
If you have any problems you think we might enjoy, please send them in. All replies should be sent to: ponder@il.ibm.com