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.

A225901 Write n in factorial base, then replace each nonzero digit d of radix k with k-d.

This page as a plain text file.
%I A225901 #72 Apr 25 2020 13:07:11
%S A225901 0,1,4,5,2,3,18,19,22,23,20,21,12,13,16,17,14,15,6,7,10,11,8,9,96,97,
%T A225901 100,101,98,99,114,115,118,119,116,117,108,109,112,113,110,111,102,
%U A225901 103,106,107,104,105,72,73,76,77,74,75,90,91,94,95,92,93,84,85,88,89,86,87,78,79,82,83,80,81,48,49,52,53,50,51,66,67,70,71,68
%N A225901 Write n in factorial base, then replace each nonzero digit d of radix k with k-d.
%C A225901 Analogous to A004488 or A048647 for the factorial base.
%C A225901 A self-inverse permutation of the natural numbers.
%C A225901 From _Antti Karttunen_, Aug 16-29 2016: (Start)
%C A225901 Consider the following way to view a factorial base representation of nonnegative integer n. For each nonzero digit d_i present in the factorial base representation of n (where i is the radix = 2.. = one more than 1-based position from the right), we place a pebble to the level (height) d_i at the corresponding column i of the triangular diagram like below, while for any zeros the corresponding columns are left empty:
%C A225901 .
%C A225901 Level
%C A225901   6        o
%C A225901           ─ ─
%C A225901   5        . .
%C A225901           ─ ─ ─
%C A225901   4        . . .
%C A225901           ─ ─ ─ ─
%C A225901   3        . . . .
%C A225901           ─ ─ ─ ─ ─
%C A225901   2        . . o . .
%C A225901           ─ ─ ─ ─ ─ ─
%C A225901   1        . o . . o o
%C A225901           ─ ─ ─ ─ ─ ─ ─
%C A225901   Radix:   7 6 5 4 3 2
%C A225901   Digits:  6 1 2 0 1 1 = A007623(4491)
%C A225901 Instead of levels, we can observe on which "slope" each pebble (nonzero digit) is located at. Formally, the slope of nonzero digit d_i with radix i is (i - d_i). Thus in above example, both the most significant digit (6) and the least significant 1 are on slope 1 (called "maximal slope", because it contains digits that are maximal allowed in those positions), while the second 1 from the right is on slope 2 ("submaximal slope").
%C A225901 This involution (A225901) sends each nonzero digit at level k to the slope k (and vice versa) by flipping such a diagram by the shallow diagonal axis that originates from the bottom right corner. Thus, from above diagram we obtain:
%C A225901 Slope (= digit's radix - digit's value)
%C A225901    1
%C A225901    2 .
%C A225901    3 .  .╲
%C A225901    4 .  .╲o╲
%C A225901    5 .  .╲.╲.╲
%C A225901    6 .  .╲.╲o╲.╲
%C A225901      .  .╲.╲.╲.╲o╲
%C A225901         o╲.╲.╲.╲.╲o╲
%C A225901         -----------------
%C A225901         1  5  3 0  2  1  = A007623(1397)
%C A225901 and indeed, a(4491) = 1397 and a(1397) = 4491.
%C A225901 Thus this permutation maps between polynomial encodings A275734 & A275735 and all the respective sequences obtained from them, where the former set of sequences are concerned with the "slopes" and the latter set with the "levels" of the factorial base representation. See the Crossrefs section.
%C A225901 Sequences A231716 and A275956 are closed with respect to this sequence, in other words, for all n, a(A231716(n)) is a term of A231716 and a(A275956(n)) is a term of A275956.
%C A225901 (End)
%H A225901 Paul Tek, <a href="/A225901/b225901.txt">Table of n, a(n) for n = 0..5039</a>
%H A225901 <a href="/index/Fa#facbase">Index entries for sequences related to factorial base representation</a>
%H A225901 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A225901 From _Antti Karttunen_, Aug 29 2016: (Start)
%F A225901 a(0) = 0; for n >= 1, a(n) = A276091(A275736(n)) + A153880(a(A257684(n))).
%F A225901 or, for n >= 1, a(n) = A276149(n) + a(A257687(n)).
%F A225901 (End)
%F A225901 Other identities. For n >= 0:
%F A225901 a(n!) = A001563(n).
%F A225901 a(n!-1) = A007489(n-1).
%F A225901 From _Antti Karttunen_, Aug 16 2016: (Start)
%F A225901 A275734(a(n)) = A275735(n) and vice versa, A275735(a(n)) = A275734(n).
%F A225901 A060130(a(n)) = A060130(n). [The flip preserves the number of nonzero digits.]
%F A225901 A153880(n) = a(A255411(a(n))) and A255411(n) = a(A153880(a(n))). [This involution conjugates between the two fundamental factorial base shifts.]
%F A225901 a(n) = A257684(a(A153880(n))) = A266193(a(A255411(n))). [Follows from above.]
%F A225901 A276011(n) = A273662(a(A273670(n))).
%F A225901 A276012(n) = A273663(a(A256450(n))).
%F A225901 (End)
%e A225901 a(1000) = a(1*6! + 2*5! + 1*4! + 2*3! + 2*2!) = (7-1)*6! + (6-2)*5! + (5-1)*4! + (4-2)*3! + (3-2)*2! = 4910.
%e A225901 a(1397) = a(1*6! + 5*5! + 3*4! + 0*3! + 2*2! + 1*1!) = (7-1)*6! + (6-5)*5! + (5-3)*4! + (3-2)*2! + (2-1)*1! = 4491.
%t A225901 b = MixedRadix[Reverse@ Range[2, 12]]; Table[FromDigits[Map[Boole[# > 0] &, #] (Reverse@ Range[2, Length@ # + 1] - #), b] &@ IntegerDigits[n, b], {n, 0, 82}] (* Version 10.2, or *)
%t A225901 f[n_] := Block[{a = {{0, n}}}, Do[AppendTo[a, {First@ #, Last@ #} &@ QuotientRemainder[a[[-1, -1]], Times @@ Range[# - i]]], {i, 0, #}] &@ NestWhile[# + 1 &, 0, Times @@ Range[# + 1] <= n &]; Most@ Rest[a][[All, 1]] /. {} -> {0}]; g[w_List] := Total[Times @@@ Transpose@ {Map[Times @@ # &, Range@ Range[0, Length@ w]], Reverse@ Append[w, 0]}]; Table[g[Map[Boole[# > 0] &, #] (Reverse@ Range[2, Length@ # + 1] - #)] &@ f@ n, {n, 0, 82}] (* _Michael De Vlieger_, Aug 29 2016 *)
%o A225901 (PARI) a(n)=my(s=0,d,k=2);while(n,d=n%k;n=n\k;if(d,s=s+(k-d)*(k-1)!);k=k+1);return(s)
%o A225901 (Scheme)
%o A225901 (define (A225901 n) (let loop ((n n) (z 0) (m 2) (f 1)) (cond ((zero? n) z) (else (loop (quotient n m) (if (zero? (modulo n m)) z (+ z (* f (- m (modulo n m))))) (+ 1 m) (* f m))))))
%o A225901 ;; One implementing the first recurrence, with memoization-macro definec:
%o A225901 (definec (A225901 n) (if (zero? n) n (+ (A276091 (A275736 n)) (A153880 (A225901 (A257684 n))))))
%o A225901 ;; _Antti Karttunen_, Aug 29 2016
%o A225901 (Python)
%o A225901 from sympy import factorial as f
%o A225901 def a(n):
%o A225901     s=0
%o A225901     k=2
%o A225901     while(n):
%o A225901         d=n%k
%o A225901         n=(n//k)
%o A225901         if d: s=s+(k - d)*f(k - 1)
%o A225901         k+=1
%o A225901     return s
%o A225901 print([a(n) for n in range(101)]) # _Indranil Ghosh_, Jun 19 2017
%Y A225901 Cf. A000142, A007623, A004488, A048647, A001563, A007489, A257684, A257687, A276091, A275736, A276149.
%Y A225901 Cf. A275959 (fixed points), A231716, A275956.
%Y A225901 Cf. A153880 & A255411.
%Y A225901 Cf. also A275734 & A275735, A275952 & A275954.
%Y A225901 This involution maps between the following sequences related to "levels" and "slopes" (see comments): A275806 <--> A060502, A257511 <--> A260736, A264990 <--> A275811, A275729 <--> A275728, A275948 <--> A275946, A275949 <--> A275947, A275964 <--> A275962, A059590 <--> A276091.
%Y A225901 Related permutations: A275957, A275958, A275835, A275836, A275837, A275838, A276011, A276012.
%K A225901 nonn,base
%O A225901 0,3
%A A225901 _Paul Tek_, May 20 2013