2011-07-25, 04:22 AM
Ah, the factorial number system! Used to map a single number n to a single permutation of an array. Been used quite much, actually. It's a good tool.
321
Noah
321
Code:
def toFNS(n):
k = 0
while fact(k) <= n:
k += 1
indexList = []
numberList = range(k).reversed()
for x in numberList:
quot = n // fact(x)
indexList.append(quot)
n %= fact(x)
return indexListNoah

