\\ returns the k-th zeroless number in base c Z(c, k) = { k--; for (w = 1, oo, if (k >= (c-1)^w, k -= (c-1)^w, return (sum (x = 0, w-1, c^x) + if (c > 2, fromdigits(digits(k, c-1), c), 0)); ); ); } a(n, b = 3) = { my (d = [], v); forprime (p = 2, oo, if (n==1, break, n % p==0, n /= p^v = valuation(n, p); d = concat(digits(Z(b, v), b), d); ); d = concat(0, d); ); fromdigits(d, b); } { for (n = 1, 10 000, print (n " " a(n)) ) } quit