login
A257684
Discard the rightmost digit from the factorial base representation of n and subtract one from all remaining nonzero digits, then convert back to decimal.
35
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, 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, 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
OFFSET
0,13
COMMENTS
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.
LINKS
FORMULA
For all n >= 0, a(A255411(n)) = n. [This sequence works as a left inverse of A255411. See A257685 for a "cleaned up" version.]
EXAMPLE
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.
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.
MATHEMATICA
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 *)
PROG
(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)))))))))
(Python)
from sympy import factorial as f
def a007623(n, p=2):
return n if n<p else a007623(n//p, p+1)*10 + n%p
def a(n):
x=str(a007623(n))[:-1]
y="".join(str(int(i) - 1) if int(i)>0 else '0' for i in x)[::-1]
return 0 if n==1 else sum(int(y[i])*f(i + 1) for i in range(len(y)))
print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 19 2017
CROSSREFS
Positions of zeros: A059590.
Can be used to define simple recurrences for sequences like A034968, A246359, A257679, A257694, A257695 and A257696.
Sequence in context: A024542 A355880 A209082 * A098424 A098428 A023193
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, May 04 2015
STATUS
approved