class MoreMath::Permutation

def unrank_indices(m)

and rank as an array of indices and return it.
Unrank the rank +m+, that is create a permutation of the appropriate size
def unrank_indices(m)
  result = Array.new(size, 0)
  for i in 0...size
    f = factorial(i)
    x = m % (f * (i + 1))
    m -= x
    x /= f
    result[size - i - 1] = x
    x -= 1
    for j in (size - i)...size
      result[j] += 1 if result[j] > x
    end
  end
  result
end