cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A266193 Decrement by 1 all maximal digits in factorial base representation of n and then shift it one digit right.

This page as a plain text file.
%I A266193 #21 Mar 14 2021 17:09:07
%S A266193 0,0,1,1,1,1,2,2,3,3,3,3,4,4,5,5,5,5,4,4,5,5,5,5,6,6,7,7,7,7,8,8,9,9,
%T A266193 9,9,10,10,11,11,11,11,10,10,11,11,11,11,12,12,13,13,13,13,14,14,15,
%U A266193 15,15,15,16,16,17,17,17,17,16,16,17,17,17,17,18,18,19,19,19,19,20,20,21,21,21,21,22,22,23,23,23,23,22
%N A266193 Decrement by 1 all maximal digits in factorial base representation of n and then shift it one digit right.
%C A266193 By "maximal digits" are here understood any digit k that occurs in position k, digit-positions numbered from the right and starting from 1. For example in A007623(677) = "53021", the digits "5" and "1" are maximal, because no larger digits will fit into those positions in a well-formed factorial base representation of a natural number.
%H A266193 Antti Karttunen, <a href="/A266193/b266193.txt">Table of n, a(n) for n = 0..10080</a>
%H A266193 <a href="/index/Fa#facbase">Index entries for sequences related to factorial base representation</a>
%F A266193 Other identities. For all n >= 0:
%F A266193 a(A153880(n)) = n.
%e A266193     n     A007623(n)  [subtract 1 from max.digits      a(n)
%e A266193         [in factorial  then shift one digit right]   [reinterpret
%e A266193                  base]                                 in decimal]
%e A266193     0         0     ->      0                         =  0
%e A266193     1         1     ->      0                         =  0
%e A266193     2        10     ->      1                         =  1
%e A266193     3        11     ->      1                         =  1
%e A266193     4        20     ->      1                         =  1
%e A266193     5        21     ->      1                         =  1
%e A266193     6       100     ->     10                         =  2
%e A266193     7       101     ->     10                         =  2
%e A266193     8       110     ->     11                         =  3
%e A266193     9       111     ->     11                         =  3
%e A266193    10       120     ->     11                         =  3
%e A266193    11       121     ->     11                         =  3
%e A266193    12       200     ->     20                         =  4
%e A266193    13       201     ->     20                         =  4
%e A266193    14       210     ->     21                         =  5
%e A266193    15       211     ->     21                         =  5
%e A266193    16       220     ->     21                         =  5
%e A266193    17       221     ->     21                         =  5
%e A266193    18       300     ->     20                         =  4
%e A266193   ...
%e A266193    23       321     ->     21                         =  5
%e A266193   119      4321     ->    321                         = 23
%o A266193 (MIT/GNU Scheme)
%o A266193 (define (A266193 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 (< d (- i 1)) 0 1)))) (+ 1 i) (if (zero? f) 1 (* f (- i 1)))))))))
%o A266193 (Python)
%o A266193 from sympy import factorial as f
%o A266193 def a007623(n, p=2): return n if n<p else a007623(n//p, p+1)*10 + n%p
%o A266193 def a(n):
%o A266193     x=str(a007623(n))[::-1]
%o A266193     y="".join(str(i) if i + 1==int(x[i]) else x[i] for i in range(len(x)))[1:]
%o A266193     return 0 if n==0 else sum(int(y[i])*f(i + 1) for i in range(len(y)))
%o A266193 print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 24 2017
%Y A266193 Cf. A007623, A257684, A266123.
%Y A266193 Left inverse of A153880.
%K A266193 nonn,base
%O A266193 0,7
%A A266193 _Antti Karttunen_, Dec 23 2015