OFFSET
0,3
COMMENTS
LINKS
EXAMPLE
For n = 1024:
- 1024 has 3 nonzero digits: 1, 2 and 4,
- so we replace the first nonzero digit by the third, the third by the first (and the second remains in place),
- and we obtain a(1024) = 4021.
PROG
(PARI) a(n, base=10) = my (d=digits(n, base), t=Vecrev(select(sign, d)), i=0); for (j=1, #d, if (d[j], d[j] = t[i++])); fromdigits(d, base)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Nov 11 2018
STATUS
approved