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

A048647 Write n in base 4, then replace each digit '1' with '3' and vice versa and convert back to decimal.

Original entry on oeis.org

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

Views

Author

John W. Layman, Jul 05 1999

Keywords

Comments

The graph of a(n) on [ 1..4^k ] resembles a plane fractal of fractal dimension 1.
Self-inverse considered as a permutation of the integers.
First 4^n terms of the sequence form a permutation s(n) of 0..4^n-1, n>=1; the number of inversions of s(n) is A115490(n). - Gheorghe Coserea, Apr 23 2018

Examples

			a(15)=5, since 15 = 33_4 -> 11_4 = 5.
		

Crossrefs

Column k=4 of A248813.

Programs

  • C
    uint32_t a(uint32_t n) { return n ^ ((n & 0x55555555) << 1); } // Falk Hüffner, Jan 22 2022
  • Haskell
    a048647 0 = 0
    a048647 n = 4 * a048647 n' + if m == 0 then 0 else 4 - m
                where (n', m) = divMod n 4
    -- Reinhard Zumkeller, Apr 08 2013
    
  • Maple
    f:= proc(n)
    option remember;
    local m, r;
    m:= n mod 4;
    r:= 4*procname((n-m)/4);
    if m = 0 then r else r + 4-m fi;
    end proc:
    f(0):= 0:
    seq(f(n),n=0..100); # Robert Israel, Nov 03 2014
    # second Maple program:
    a:= proc(n) option remember; `if`(n=0, 0,
          a(iquo(n, 4, 'r'))*4+[0, 3, 2, 1][r+1])
        end:
    seq(a(n), n=0..70);  # Alois P. Heinz, Jan 25 2022
  • Mathematica
    Table[FromDigits[If[#==0,0,4-#]&/@IntegerDigits[n,4],4],{n,0,70}] (* Harvey P. Dale, Jul 23 2012 *)
  • PARI
    a(n)=fromdigits(apply(d->if(d,4-d),digits(n,4)),4) \\ Charles R Greathouse IV, Jun 23 2017
    
  • Python
    from sympy.ntheory.factor_ import digits
    def a(n):
        return int("".join(str(4 - d) if d!=0 else '0' for d in digits(n, 4)[1:]), 4)
    print([a(n) for n in range(101)]) # Indranil Ghosh, Jun 26 2017
    
  • Python
    def A048647(n): return n^((n&((1<<(m:=n.bit_length())+(m&1))-1)//3)<<1) # Chai Wah Wu, Jan 29 2023
    

Formula

a(n) = if n = 0 then 0 else 4*a(floor(n/4)) + if m = 0 then 0 else 4 - m, where m = n mod 4. - Reinhard Zumkeller, Apr 08 2013
G.f. g(x) satisfies: g(x) = 4*(1+x+x^2+x^3)*g(x^4) + (3*x+2*x^2+x^3)/(1-x^4). - Robert Israel, Nov 03 2014

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)

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

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

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Crossrefs

Column k=6 of A248813.

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

Original entry on oeis.org

0, 6, 5, 4, 3, 2, 1, 42, 48, 47, 46, 45, 44, 43, 35, 41, 40, 39, 38, 37, 36, 28, 34, 33, 32, 31, 30, 29, 21, 27, 26, 25, 24, 23, 22, 14, 20, 19, 18, 17, 16, 15, 7, 13, 12, 11, 10, 9, 8, 294, 300, 299, 298, 297, 296, 295, 336, 342, 341, 340, 339, 338, 337, 329, 335, 334
Offset: 0

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Crossrefs

Column k=7 of A248813.

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

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Crossrefs

Column k=8 of A248813.

Programs

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

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

Original entry on oeis.org

0, 8, 7, 6, 5, 4, 3, 2, 1, 72, 80, 79, 78, 77, 76, 75, 74, 73, 63, 71, 70, 69, 68, 67, 66, 65, 64, 54, 62, 61, 60, 59, 58, 57, 56, 55, 45, 53, 52, 51, 50, 49, 48, 47, 46, 36, 44, 43, 42, 41, 40, 39, 38, 37, 27, 35, 34, 33, 32, 31, 30, 29, 28, 18, 26, 25, 24, 23, 22, 21, 20, 19
Offset: 0

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Crossrefs

Column k=9 of A248813.

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

Original entry on oeis.org

0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 110, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 99, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 88, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 77, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 66, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67
Offset: 0

Views

Author

Henry Bottomley, Apr 19 2000

Keywords

Crossrefs

Column k=11 of A248813.
Showing 1-10 of 14 results. Next