How to avoid base-$8$ numbers that contain zeros? I'm looking for a formula that produces numbers in base-$8$ of length $k$, that contain no $0$'s, except for the most significant digit. All numbers are padded with leading zeros.  For example, with $k = 1$ we have $\lbrace 0,1,2,3,4,5,6,7\rbrace$. For $k=2$, we skip $00$ and have $\lbrace 01,02,\ldots,07,(\text{skip }10),11,12,\dots,17,(\text{skip }20), 21,\ldots, 75, 76,77\rbrace$.  For $k=3$, we skip $000$ through $010$, so the first element in this set is $011$, and proceed as above for the remaining values through $077$, then (skipping $100$ through $110$) on to $111$, $112$, etc., all the way to $777$. 
With such a formula I would be able to have a function like f($k$, $a$, $b$) that outputs all such numbers of length $k$ in the decimal range ($a$,$b$).  Is such a formula possible?
 A: It looks from the examples that you allow one leading $0$, but no more than that, and no non-leading $0$'s.  There are $8$ choices for the lead "digit," and for each such choice there are $7^{k-1}$ ways to choose the rest, for a total of $8\cdot 7^{k-1}$. 
A: Let $i$ iterate from $1$ to $k$, and generate all strings of length $i$ from $\{1,\ldots,7\}$, and then append 0s at the beginning. There will be $7+7^2+\cdots+7^k=\frac{7^{k+1}-7}{6}$ such strings.
A: You want $k$ base-$8$ digits of which the first is allowed to be anything and the others must be $1$ to $7$.  For any choice of the first digit there are $7^{k-1}$ choices for the others.
If you want an explicit "formula" to generate these: note that the $m$'th base-$b$ digit from the end of positive integer $x$ is $$f(b,m,x) = \lfloor x/b^{m-1} \rfloor \mod b$$
So consider
$$F(x) = \lfloor x/7^k \rfloor 8^k + \sum_{m=0}^{k-1} ((\lfloor x/7^m \rfloor \mod 7)+1) 8^m$$
which will enumerate your desired numbers for $x$ from $0$ to $8 \times 7^{k-1} - 1$.
