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.

Showing 1-10 of 23 results. Next

A004488 Tersum n + n.

Original entry on oeis.org

0, 2, 1, 6, 8, 7, 3, 5, 4, 18, 20, 19, 24, 26, 25, 21, 23, 22, 9, 11, 10, 15, 17, 16, 12, 14, 13, 54, 56, 55, 60, 62, 61, 57, 59, 58, 72, 74, 73, 78, 80, 79, 75, 77, 76, 63, 65, 64, 69, 71, 70, 66, 68, 67, 27, 29, 28, 33, 35, 34, 30, 32, 31, 45, 47, 46, 51
Offset: 0

Views

Author

Keywords

Comments

Could also be described as "Write n in base 3, then replace each digit with its base-3 negative" as with A048647 for base 4. - Henry Bottomley, Apr 19 2000
a(a(n)) = n, a self-inverse permutation of the nonnegative integers. - Reinhard Zumkeller, Dec 19 2003
First 3^n terms of the sequence form a permutation s(n) of 0..3^n-1, n>=1; the number of inversions of s(n) is A016142(n-1). - Gheorghe Coserea, Apr 23 2018

Crossrefs

Programs

  • Haskell
    a004488 0 = 0
    a004488 n = if d == 0 then 3 * a004488 n' else 3 * a004488 n' + 3 - d
                where (n', d) = divMod n 3
    -- Reinhard Zumkeller, Mar 12 2014
    
  • Maple
    a:= proc(n) local t, r, i;
          t, r:= n, 0;
          for i from 0 while t>0 do
            r:= r+3^i *irem(2*irem(t, 3, 't'), 3)
          od; r
        end:
    seq(a(n), n=0..80);  # Alois P. Heinz, Sep 07 2011
  • Mathematica
    a[n_] := FromDigits[Mod[3-IntegerDigits[n, 3], 3], 3]; Table[a[n], {n, 0, 66}] (* Jean-François Alcover, Mar 03 2014 *)
  • PARI
    a(n) = my(b=3); fromdigits(apply(d->(b-d)%b, digits(n, b)), b);
    vector(67, i, a(i-1))  \\ Gheorghe Coserea, Apr 23 2018
    
  • Python
    from sympy.ntheory.factor_ import digits
    def a(n): return int("".join([str((3 - i)%3) for i in digits(n, 3)[1:]]), 3) # Indranil Ghosh, Jun 06 2017

Formula

Tersum m + n: write m and n in base 3 and add mod 3 with no carries, e.g., 5 + 8 = "21" + "22" = "10" = 1.
a(n) = Sum(3-d(i)-3*0^d(i): n=Sum(d(i)*3^d(i): 0<=d(i)<3)). - Reinhard Zumkeller, Dec 19 2003
a(3*n) = 3*a(n), a(3*n+1) = 3*a(n)+2, a(3*n+2) = 3*a(n)+1. - Robert Israel, May 09 2014

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

Original entry on oeis.org

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, 100, 101, 98, 99, 114, 115, 118, 119, 116, 117, 108, 109, 112, 113, 110, 111, 102, 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
Offset: 0

Views

Author

Paul Tek, May 20 2013

Keywords

Comments

Analogous to A004488 or A048647 for the factorial base.
A self-inverse permutation of the natural numbers.
From Antti Karttunen, Aug 16-29 2016: (Start)
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:
.
Level
6 o
─ ─
5 . .
─ ─ ─
4 . . .
─ ─ ─ ─
3 . . . .
─ ─ ─ ─ ─
2 . . o . .
─ ─ ─ ─ ─ ─
1 . o . . o o
─ ─ ─ ─ ─ ─ ─
Radix: 7 6 5 4 3 2
Digits: 6 1 2 0 1 1 = A007623(4491)
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").
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:
Slope (= digit's radix - digit's value)
1
2 .
3 . .╲
4 . .╲o╲
5 . .╲.╲.╲
6 . .╲.╲o╲.╲
. .╲.╲.╲.╲o╲
o╲.╲.╲.╲.╲o╲
-----------------
1 5 3 0 2 1 = A007623(1397)
and indeed, a(4491) = 1397 and a(1397) = 4491.
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.
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.
(End)

Examples

			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.
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.
		

Crossrefs

Cf. A275959 (fixed points), A231716, A275956.
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.

Programs

  • Mathematica
    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 *)
    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 *)
  • 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)
    
  • Python
    from sympy import factorial as f
    def a(n):
        s=0
        k=2
        while(n):
            d=n%k
            n=(n//k)
            if d: s=s+(k - d)*f(k - 1)
            k+=1
        return s
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 19 2017
  • Scheme
    (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))))))
    ;; One implementing the first recurrence, with memoization-macro definec:
    (definec (A225901 n) (if (zero? n) n (+ (A276091 (A275736 n)) (A153880 (A225901 (A257684 n))))))
    ;; Antti Karttunen, Aug 29 2016
    

Formula

From Antti Karttunen, Aug 29 2016: (Start)
a(0) = 0; for n >= 1, a(n) = A276091(A275736(n)) + A153880(a(A257684(n))).
or, for n >= 1, a(n) = A276149(n) + a(A257687(n)).
(End)
Other identities. For n >= 0:
a(n!) = A001563(n).
a(n!-1) = A007489(n-1).
From Antti Karttunen, Aug 16 2016: (Start)
A275734(a(n)) = A275735(n) and vice versa, A275735(a(n)) = A275734(n).
A060130(a(n)) = A060130(n). [The flip preserves the number of nonzero digits.]
A153880(n) = a(A255411(a(n))) and A255411(n) = a(A153880(a(n))). [This involution conjugates between the two fundamental factorial base shifts.]
a(n) = A257684(a(A153880(n))) = A266193(a(A255411(n))). [Follows from above.]
A276011(n) = A273662(a(A273670(n))).
A276012(n) = A273663(a(A256450(n))).
(End)

A055120 Digital complement of n (replace each nonzero digit d with 10-d).

Original entry on oeis.org

0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 90, 99, 98, 97, 96, 95, 94, 93, 92, 91, 80, 89, 88, 87, 86, 85, 84, 83, 82, 81, 70, 79, 78, 77, 76, 75, 74, 73, 72, 71, 60, 69, 68, 67, 66, 65, 64, 63, 62, 61, 50, 59, 58, 57, 56, 55, 54, 53, 52, 51, 40, 49, 48, 47, 46, 45, 44, 43, 42, 41, 30, 39
Offset: 0

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Comments

a(n) = -n in carryless arithmetic mod 10 - that is, n + a(n) = 0 (cf. A169894). - N. J. A. Sloane, Aug 03 2010

Examples

			a(11) = 99 because 1 + 9 = 0 mod 10 for each digit.
a(20) = 80 because 2 + 8 = 0 mod 10 and 0 + 0 = 0 mod 10.
		

Crossrefs

Column k=10 of A248813.

Programs

  • Haskell
    a055120 = foldl f 0 . reverse . unfoldr g where
       f v d = if d == 0 then 10 * v else 10 * v + 10 - d
       g x = if x == 0 then Nothing else Just $ swap $ divMod x 10
    -- Reinhard Zumkeller, Oct 04 2011
    
  • Maple
    f:=proc(n) local t0,t1,i;
    t0:=0; t1:=convert(n,base,10);
    for i from 1 to nops(t1) do
    if t1[i]>0 then t0:=t0+(10-t1[i])*10^(i-1); fi;
    od:
    RETURN(t0);
    end;
    # N. J. A. Sloane, Jan 21 2011
  • Mathematica
    a[n_] := FromDigits[ IntegerDigits[n] /. d_?Positive -> 10-d]; Table[a[n], {n, 0, 100}](* Jean-François Alcover, Nov 28 2011 *)
  • PARI
    a(n)=fromdigits(apply(d->if(d,10-d,0),digits(n))) \\ Charles R Greathouse IV, Feb 08 2017
    
  • Python
    def A055120(n): return int(''.join(str(10-int(d)) if d != '0' else d for d in str(n))) # Chai Wah Wu, Apr 03 2021

Formula

From Robert Israel, Sep 04 2017: (Start)
a(10*n) = 10*a(n).
a(10*n+j) = 10*a(n) + 10 - j for 1 <= j <= 9.
G.f. g(x) satisfies g(x) = 10*(1+x+x^2+...+x^9)*g(x^10) + (9*x+8*x^2+7*x^3+6*x^4+5*x^5+4*x^6+3*x^7+2*x^8+x^9)/(1-x^10).
(End)

A248813 A(n,k) is the base-k complement of n; square array A(n,k), n>=0, k>=2, read by antidiagonals.

Original entry on oeis.org

0, 0, 1, 0, 2, 2, 0, 3, 1, 3, 0, 4, 2, 6, 4, 0, 5, 3, 1, 8, 5, 0, 6, 4, 2, 12, 7, 6, 0, 7, 5, 3, 1, 15, 3, 7, 0, 8, 6, 4, 2, 20, 14, 5, 8, 0, 9, 7, 5, 3, 1, 24, 13, 4, 9, 0, 10, 8, 6, 4, 2, 30, 23, 8, 18, 10, 0, 11, 9, 7, 5, 3, 1, 35, 22, 11, 20, 11, 0, 12, 10, 8, 6, 4, 2, 42, 34, 21, 10, 19, 12
Offset: 0

Views

Author

Alois P. Heinz, Mar 03 2015

Keywords

Comments

Every column is a permutation of the nonnegative integers.

Examples

			Square array A(n,k) begins:
   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, ...
   1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, ...
   2,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, ...
   3,  6,  1,  2,  3,  4,  5,  6,  7,  8,  9, ...
   4,  8, 12,  1,  2,  3,  4,  5,  6,  7,  8, ...
   5,  7, 15, 20,  1,  2,  3,  4,  5,  6,  7, ...
   6,  3, 14, 24, 30,  1,  2,  3,  4,  5,  6, ...
   7,  5, 13, 23, 35, 42,  1,  2,  3,  4,  5, ...
   8,  4,  8, 22, 34, 48, 56,  1,  2,  3,  4, ...
   9, 18, 11, 21, 33, 47, 63, 72,  1,  2,  3, ...
  10, 20, 10, 15, 32, 46, 62, 80, 90,  1,  2, ...
		

Crossrefs

Programs

  • Maple
    A:= proc(n, k) local t, r, i; t, r:= n, 0;
          for i from 0 while t>0 do
            r:= r+k^i *irem(k-irem(t, k, 't'), k)
          od; r
        end:
    seq(seq(A(n, 2+d-n), n=0..d), d=0..14);
  • PARI
    A(n,k)=fromdigits(apply(d->(k-d)%k, digits(n, k)), k); \\ Gheorghe Coserea, Apr 23 2018

A055115 Base-5 complement of n (write n in base 5, then replace each digit with its base-5 negative).

Original entry on oeis.org

0, 4, 3, 2, 1, 20, 24, 23, 22, 21, 15, 19, 18, 17, 16, 10, 14, 13, 12, 11, 5, 9, 8, 7, 6, 100, 104, 103, 102, 101, 120, 124, 123, 122, 121, 115, 119, 118, 117, 116, 110, 114, 113, 112, 111, 105, 109, 108, 107, 106, 75, 79, 78, 77, 76, 95, 99, 98, 97, 96, 90, 94, 93, 92
Offset: 0

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Crossrefs

Column k=5 of A248813.

A055126 Base-16 complement of n (write n in base 16, then replace each digit with its base-16 negative).

Original entry on oeis.org

0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 240, 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 224, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 208, 223, 222, 221, 220, 219, 218, 217, 216, 215
Offset: 0

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Crossrefs

Column k=16 of A248813.

Programs

  • Haskell
    a055126 0 = 0
    a055126 n = if d == 0 then 16 * a055126 n' else 16 * a055126 n' + 16 - d
                where (n', d) = divMod n 16
    -- Reinhard Zumkeller, Mar 12 2014

A163241 Simple self-inverse permutation: Write n in base 4, then replace each digit '2' with '3' and vice versa, then convert back to decimal.

Original entry on oeis.org

0, 1, 3, 2, 4, 5, 7, 6, 12, 13, 15, 14, 8, 9, 11, 10, 16, 17, 19, 18, 20, 21, 23, 22, 28, 29, 31, 30, 24, 25, 27, 26, 48, 49, 51, 50, 52, 53, 55, 54, 60, 61, 63, 62, 56, 57, 59, 58, 32, 33, 35, 34, 36, 37, 39, 38, 44, 45, 47, 46, 40, 41, 43, 42, 64, 65, 67, 66, 68, 69, 71, 70
Offset: 0

Views

Author

Antti Karttunen, Jul 29 2009

Keywords

Examples

			43 in quaternary base (A007090) is written as '223' (2*16 + 2*4 + 3), which is then mapped to '332' = 3*16 + 3*4 + 2 = 62, thus a(43) = 62, and likewise a(62) = 43.
		

Crossrefs

Programs

  • C
    uint32_t a(uint32_t n) { return n ^ ((n >> 1) & 0x55555555); } // Falk Hüffner, Jan 22 2022
  • Maple
    a:= proc(n) option remember; `if`(n=0, 0,
          a(iquo(n, 4, 'r'))*4+[0, 1, 3, 2][r+1])
        end:
    seq(a(n), n=0..71);  # Alois P. Heinz, Jan 25 2022
  • Mathematica
    Table[FromDigits[IntegerDigits[n,4]/.{2->a,3->b}/.{a->3,b->2},4],{n,0,75}] (* Harvey P. Dale, Nov 29 2011 *)
  • PARI
    f(d) = if (d==2, 4, if (x==d, 2, d));
    a(n) = fromdigits(apply(f, digits(n, 4)), 4); \\ Michel Marcus, Jun 28 2017
    
  • Python
    def a000695(n):
        n=bin(n)[2:]
        x=len(n)
        return sum([int(n[i])*4**(x - 1 - i) for i in range(x)])
    def a059905(n): return sum([(n>>2*i&1)<Indranil Ghosh, Jun 26 2017
    
  • Scheme
    (define (A163241 n) (+ (A000695 (A003987bi (A059905 n) (A059906 n))) (* 2 (A000695 (A059906 n)))))
    

Formula

a(n) = A000695(A003987bi(A059905(n),A059906(n))) + 2*A000695(A059906(n)), where A003987bi is binary XOR.

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A065256 Quintal Queens permutation of N: halve or multiply by 3 (mod 5) each digit (0->0, 1->3, 2->1, 3->4, 4->2) of the base 5 representation of n.

Original entry on oeis.org

0, 3, 1, 4, 2, 15, 18, 16, 19, 17, 5, 8, 6, 9, 7, 20, 23, 21, 24, 22, 10, 13, 11, 14, 12, 75, 78, 76, 79, 77, 90, 93, 91, 94, 92, 80, 83, 81, 84, 82, 95, 98, 96, 99, 97, 85, 88, 86, 89, 87, 25, 28, 26, 29, 27, 40, 43, 41, 44, 42, 30, 33, 31, 34, 32, 45, 48, 46, 49, 47, 35, 38
Offset: 0

Author

Antti Karttunen, Oct 26 2001

Keywords

Comments

All the permutations A004515 and A065256-A065258 consist of the first fixed term ("Queen on the corner") plus infinitely many 4-cycles and they satisfy the "nonattacking queen condition" that p(i+d) <> p(i)+-d for all i and d >= 1.
The corresponding infinite permutation matrix is a scale-invariant fractal (cf. A048647) and any subarray (5^i) X (5^i) (i >= 1) cut from its corner gives a solution to the case n=5^i of the n nonattacking queens on n X n chessboard (A000170). Is there any permutation of N which would give solutions to the queen problem with more frequent intervals than A000351?

Crossrefs

Inverse permutation: A004515. A065256[n] = A065258[n+1]-1. Cf. also A065187, A065189.

Programs

  • Maple
    [seq(QuintalQueens0Inv(j),j=0..124)];
    HalveDigit := (d,b) -> op(2,op(1,msolve(2*x=d,b))); # b should be an odd integer >= 3 and d should be in range [0,b-1].
    HalveDigits := proc(n,b) local i; add((b^i)*HalveDigit((floor(n/(b^i)) mod b),b),i=0..floor(evalf(log[b](n+1)))+1); end;
    QuintalQueens0Inv := n -> HalveDigits(n,5);
  • Mathematica
    HalveDigit[d_, b_ /; OddQ[b] && b >= 3] /; 0 <= d <= b - 1 := Module[{x}, x /. Solve[2*x == d, x, Modulus -> b][[1]]];
    HalveDigits[n_, b_] := Sum[b^i*HalveDigit[Mod[Floor[n/b^i] , b], b], {i, 0, Floor[Log[b, n + 1]]}];
    QuintalQueens0Inv[n_] := HalveDigits[n, 5];
    Table[QuintalQueens0Inv[n], {n, 0, 80}] (* Jean-François Alcover, Mar 05 2016, adapted from Maple *)

Extensions

Edited by Charles R Greathouse IV, Nov 01 2009

A055116 Base-6 complement of n (write n in base 6, then replace each digit with its base-6 negative).

Original entry on oeis.org

0, 5, 4, 3, 2, 1, 30, 35, 34, 33, 32, 31, 24, 29, 28, 27, 26, 25, 18, 23, 22, 21, 20, 19, 12, 17, 16, 15, 14, 13, 6, 11, 10, 9, 8, 7, 180, 185, 184, 183, 182, 181, 210, 215, 214, 213, 212, 211, 204, 209, 208, 207, 206, 205, 198, 203, 202, 201, 200, 199, 192, 197, 196
Offset: 0

Author

Henry Bottomley, Apr 19 2000

Keywords

Crossrefs

Column k=6 of A248813.

A318722 Let f(0) = 0 and f(t*4^k + u) = i^t * ((1+i) * 2^k - f(u)) for any t in {1, 2, 3} and k >= 0 and u such that 0 <= u < 4^k (i denoting the imaginary unit); for any n >= 0, let g(n) = (f(A042968(n)) - 1 - i) / 2; a(n) is the real part of g(n).

Original entry on oeis.org

-1, -1, 0, -1, -2, -2, -2, -2, -1, 0, 1, 1, -2, -3, -3, -1, -1, -2, -3, -4, -4, -4, -4, -3, -3, -3, -2, -3, -4, -4, -4, -4, -3, -2, -1, -1, 1, 2, 2, 0, 0, 1, 2, 3, 3, 3, 3, 2, -4, -5, -5, -3, -3, -4, -5, -6, -6, -6, -6, -5, -2, -2, -3, -2, -1, -1, -1, -1, -2
Offset: 0

Author

Rémy Sigrist, Sep 02 2018

Keywords

Comments

See A318723 for the imaginary part of g.
See A318724 for the square of the modulus of g.
This sequence can be computed by considering the base 4 representation of A042968, hence the keyword base.
The function g runs uniquely through the set of Gaussian integers z such that Re(z) < 0 or Im(z) < 0.
The function g is related to the numbering of the cells in a Chair tiling (see representation of g(n) in Links section).
This sequence has similarities with A316657.

Crossrefs

Programs

  • PARI
    a(n) = my (d=Vecrev(digits(1+n+n\3,4)), z=0); for (k=1, #d, if (d[k], z = I^d[k] * (-z + (1+I) * 2^(k-1)))); real((z-1-I)/2)

Formula

a(n) = A318723(n) iff the base 4 representation of A042968(n) contains only 0's and 2's.
If A048647(A042968(m)) = A042968(n), then a(m) = A318723(n) and A318723(m) = a(n).
Showing 1-10 of 23 results. Next