%I #29 Mar 10 2021 09:34:09
%S 0,0,0,0,1,1,0,0,0,0,1,1,2,2,2,2,3,3,4,4,4,4,5,5,0,0,0,0,1,1,0,0,0,0,
%T 1,1,2,2,2,2,3,3,4,4,4,4,5,5,6,6,6,6,7,7,6,6,6,6,7,7,8,8,8,8,9,9,10,
%U 10,10,10,11,11,12,12,12,12,13,13,12,12,12,12,13,13,14,14,14,14,15,15,16,16,16,16,17,17
%N Discard the rightmost digit from the factorial base representation of n and subtract one from all remaining nonzero digits, then convert back to decimal.
%C In other words, subtract one from all nonzero digits in the factorial base representation (A007623) of n and shift it one step right (i.e., delete the rightmost zero), then convert back to decimal.
%H Antti Karttunen, <a href="/A257684/b257684.txt">Table of n, a(n) for n = 0..10080</a>
%F For all n >= 0, a(A255411(n)) = n. [This sequence works as a left inverse of A255411. See A257685 for a "cleaned up" version.]
%e For 4, whose factorial base representation is "20" (as 4 = 2*2! + 0*1!), when we discard the rightmost zero, and subtract 1 from 2, we get "1", thus a(4) = 1.
%e For 18, whose factorial base representation is "300" (as 18 = 3*3! + 0*2! + 0*1!), when we discard the rightmost zero, and subtract 1 from 3, we get "20", thus a(18) = 4.
%t nn = 95; m = 1; While[Factorial@ m < nn, m++]; m; Map[FromDigits[#, MixedRadix[Reverse@ Range[2, m]]] &[If[# == 0, 0, # - 1] & /@ Most@ IntegerDigits[#, MixedRadix[Reverse@ Range[2, m]]]] &, Range[0, nn]] (* _Michael De Vlieger_, Aug 11 2016, Version 10.2 *)
%o (Scheme) (define (A257684 n) (let loop ((n n) (z 0) (i 2) (f 0)) (cond ((zero? n) z) (else (let ((d (remainder n i))) (loop (quotient n i) (+ z (* f (- d (if (zero? d) 0 1)))) (+ 1 i) (if (zero? f) 1 (* f (- i 1)))))))))
%o (Python)
%o from sympy import factorial as f
%o def a007623(n, p=2):
%o return n if n<p else a007623(n//p, p+1)*10 + n%p
%o def a(n):
%o x=str(a007623(n))[:-1]
%o y="".join(str(int(i) - 1) if int(i)>0 else '0' for i in x)[::-1]
%o return 0 if n==1 else sum(int(y[i])*f(i + 1) for i in range(len(y)))
%o print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 19 2017
%Y Positions of zeros: A059590.
%Y Cf. A007623, A255411, A257685, A257687.
%Y Can be used to define simple recurrences for sequences like A034968, A246359, A257679, A257694, A257695 and A257696.
%K nonn,base
%O 0,13
%A _Antti Karttunen_, May 04 2015