Say you have the finite alphabet $\{a,b,c,d,e,f,g\}$ and an enumeration of finite strings over it by the shortlex order (length-lexicographic ordering), starting with the empty string, i.e., $\epsilon, a, b, c, d, e, f, g,$ $aa, ab, ac, \cdots,$ $gg, \cdots, aaa, aab, aac,$ $\cdots, ggg, \cdots$.
What's the most efficient algorithm to get a string from that sequence by its index? For example, given 9, we should get $ab$.
Basically, I'm looking for a fast procedure that takes an integer $x$ and returns the $x$-th string from a list of strings enumerated over a fixed, finite alphabet.