Given an increasing identity index on n items [ 0, 1, ..., n-1 ], a value can be calculated by considering each entry as a number in base n and with place value corresponding to it's location (powers of n, right-to-left).
For increasing n I calculate:
2 -> [0,1] -> 1
3 -> [0,1,2] -> (1.3 + 2) = 5
4 -> [0,1,2,3] -> (1.4^2 + 2.4 + 3) = 27
5 -> [0,1,2,3,4] -> (1.5^3 + 2.5^2 + 3.5 + 4) = 194
6 -> [0,1,2,3,4,5] -> (1.6^4 + 2.6^3 + 3.6^2 + 4.6 + 5) = 1865
It's fairly easy to calculate these numbers by brute force, but is there a nice function that provides the same result?
I'm interested in the permutations of an identity index and how they're distributed within the space of the base box (i.e. the calculation above), since they must produce select values between 0 and (nn - 1).
I can already express (and code) the function as a summation.