Calculate permutations (#715)