login
A387909
Consider the factorial base expansion of n, without leading zeros, say (d(1), ..., d(w)); for k = 2..floor(w/2), if d(k) <= k then exchange d(k) and d(w+1-k); the resulting digits correspond to the factorial base expansion of a(n).
1
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 30, 31, 36, 37, 26, 27, 32, 33, 38, 39, 28, 29, 34, 35, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 54, 55, 60, 61, 50, 51, 56, 57, 62, 63, 52, 53, 58, 59, 64, 65, 66, 67
OFFSET
0,3
COMMENTS
A self-inverse permutation of the nonnegative integers that preserves the number of digits (A084558) and the sum of digits (A034968) in factorial base.
FORMULA
a(a(n)) = n.
EXAMPLE
For n = 1361: the factorial base expansion of 1361 is (d(1), ..., d(6)) = (1,5,1,2,2,1); d(2) = 5 > 2 so we don't alter d(2) and d(5); d(3) = 1 <= 3 so we exchange d(3) and d(4); the resulting digits, (1,5,2,1,2,1), correspond to 1379, so a(1361) = 1379.
PROG
(PARI) factdigits(n) = { my (dd=[]); for (r=2, oo, if (n==0, return (dd), dd=concat(n%r, dd); n\=r; ); ); }
fromfactdigits(d) = { sum (k=1, #d, d[#d+1-k]*k!); }
a(n) = {
my (d = factdigits(n));
for (k = 2, #d\2, if (d[k] <= k, [d[k], d[#d+1-k]] = [d[#d+1-k], d[k]]; ); );
fromfactdigits(d);
}
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Oct 12 2025
STATUS
approved