```
def getPermutation(self, n, k):
def this_pos(cands, k, pre):
if len(cands) == 1:
return pre + str(cands[0])
fact = math.factorial(len(cands)-1)
ind = (k-1) / fact
this = cands[ind]
return this_pos(cands[:ind] + cands[ind+1:], ((k-1) % fact) + 1, pre+str(this))
return this_pos(range(1, n+1), k, "")
```