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

A007608 Nonnegative integers in base -4.

Original entry on oeis.org

0, 1, 2, 3, 130, 131, 132, 133, 120, 121, 122, 123, 110, 111, 112, 113, 100, 101, 102, 103, 230, 231, 232, 233, 220, 221, 222, 223, 210, 211, 212, 213, 200, 201, 202, 203, 330, 331, 332, 333, 320, 321, 322, 323, 310, 311, 312, 313, 300, 301, 302, 303, 13030
Offset: 0

Views

Author

Keywords

Comments

The base 2i representation (quater-imaginary representation) of nonnegative integers is obtained by interleaving with zeros, cf. A212494.
More precisely, a(n) is the number n written in base -4; numbers [which represent some nonnegative integer] in base -4 are 0, 1, 2, 3, 100, 101, 102, 103, 110, 111, 112, 113, 120, 121, 122, 123, 130, 131, 132, 133, ... (A212556) - M. F. Hasler, May 20 2012

References

  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1969, Vol. 2, p. 189.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A212556 (sorted), A066323 (sum of digits), A212526 (negative integers in base -4).

Programs

  • Haskell
    a007608 0 = 0
    a007608 n = a007608 n' * 10 + m where
       (n', m) = if r < 0 then (q + 1, r + 4) else (q, r)
                 where (q, r) = quotRem n (negate 4)
    -- Reinhard Zumkeller, Jul 15 2012
    
  • Mathematica
    ToNegaBases[i_Integer, b_Integer] := FromDigits[ Rest[ Reverse[ Mod[ NestWhileList[(#1 - Mod[ #1, b])/-b &, i, #1 != 0 &], b]]]]; Table[ ToNegaBases[n, 4], {n, 0, 55}]
  • PARI
    A007608(n,s="")={until(!n\=-4,s=Str(n%-4,s));eval(s)}  \\ M. F. Hasler, May 20 2012
    
  • Python
    def A007608(n):
        s, q = '', n
        while q >= 4 or q < 0:
            q, r = divmod(q, -4)
            if r < 0:
                q += 1
                r += 4
            s += str(r)
        return int(str(q)+s[::-1]) # Chai Wah Wu, Apr 09 2016

A212529 Negative numbers in base -2.

Original entry on oeis.org

11, 10, 1101, 1100, 1111, 1110, 1001, 1000, 1011, 1010, 110101, 110100, 110111, 110110, 110001, 110000, 110011, 110010, 111101, 111100, 111111, 111110, 111001, 111000, 111011, 111010, 100101, 100100, 100111, 100110, 100001, 100000, 100011, 100010, 101101, 101100, 101111, 101110, 101001, 101000, 101011, 101010, 11010101
Offset: 1

Views

Author

Joerg Arndt, May 20 2012

Keywords

Comments

The formula a(n) = A039724(-n) is slightly misleading because sequence A039724 isn't defined for n < 0, and none of the terms a(n) is a term of A039724. It can be seen as the definition of the extension of A039724 to negative indices. Also, recursive definitions or implementations of A039724 require that function to be defined for negative arguments, and using a generic formula it will work as expected for -n, n > 0. - M. F. Hasler, Oct 18 2018

Crossrefs

Cf. A039724 (nonnegative numbers in base -2).
Cf. A007608 (nonnegative numbers in base -4), A212526 (negative numbers in base -4).
Cf. A005352.

Programs

  • Haskell
    a212529 = a039724 . negate  -- Reinhard Zumkeller, Feb 05 2014
    
  • Maple
    a:= proc(n) local d, i, l, m;
          m:= n; l:= NULL;
          for i from 0 while m>0 do
            d:= irem(m, 2, 'm');
            if d=1 and irem(i, 2)=0 then m:= m+1 fi;
            l:= d, l
          od; parse(cat(l))
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, May 20 2012
  • Mathematica
    negabin[n_] := negabin[n] = If[n == 0, 0, negabin[Quotient[n - 1, -2]]*10 + Mod[n, 2]]; a[n_] := negabin[-n]; Array[a, 50] (* Amiram Eldar, Jul 23 2023 *)
  • PARI
    A212529(n)=A039724(-n) \\ M. F. Hasler, Oct 16 2018
  • Python
    def A212529(n):
        s, q = '', -n
        while q >= 2 or q < 0:
            q, r = divmod(q, -2)
            if r < 0:
                q += 1
                r += 2
            s += str(r)
        return int(str(q)+s[::-1]) # Chai Wah Wu, Apr 09 2016
    

Formula

a(n) = A039724(-n). - Reinhard Zumkeller, Feb 05 2014

A256441 Binary representation of base-(i-1) expansion of -n: replace i-1 with 2 in base-(i-1) expansion of -n.

Original entry on oeis.org

0, 29, 28, 17, 16, 205, 204, 193, 192, 221, 220, 209, 208, 7437, 7436, 7425, 7424, 7453, 7452, 7441, 7440, 7629, 7628, 7617, 7616, 7645, 7644, 7633, 7632, 7181, 7180, 7169, 7168, 7197, 7196, 7185, 7184, 7373, 7372, 7361, 7360, 7389, 7388, 7377, 7376, 4365
Offset: 0

Views

Author

Paul Tek, Mar 29 2015

Keywords

Comments

Here i = sqrt(-1).
From Jianing Song, Jan 22 2023: (Start)
Also binary representation of base-(-1-i) expansion of -n.
Write out -n in base -4 (A212526), change each digit 0, 1, 2, 3 to 0000, 0001, 1100, 1101 respectively, then interpret as a binary number. (End)

Examples

			a(5) = 205 = 2^7 + 2^6 + 2^3 + 2^2 + 2^0 since (i-1)^7 + (i-1)^6 + (i-1)^3 + (i-1)^2 + (i-1)^0 = -5.
		

Crossrefs

Cf. A066321.

Programs

  • PARI
    a(n) = my(v = [-n,0], x=0, digit=0, a, b); while(v!=[0,0], a=v[1]; b=v[2]; v[1]=-2*(a\2)+b; v[2]=-(a\2); x+=(a%2)*2^digit; digit++); x \\ Jianing Song, Jan 22 2023; [a,b] represents the number a + b*(-1+i)
  • Perl
    See Links section.
    

Formula

For n >= 1, a(4*n-0..3) = 16 * A066321(n) + 0, 1, 12, 13 respectively. - Jianing Song, Jan 22 2023

A305238 Negative numbers in base -10.

Original entry on oeis.org

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

Views

Author

Jianing Song, Jun 19 2018

Keywords

Comments

a(n) = A039723(-n).
Also base -10 representation of -n reinterpreted as decimal numbers.
The first comment is slightly misleading because sequence A039723 isn't defined for n < 0, and none of the terms a(n) here is a term of A039723. However, it can be seen as the definition of the extension of A039723 to negative indices. Also, the (naïve) recursive definition or implementation of A039723 requires that function to be defined for negative arguments, and using the generic formula it will work as expected for -n, n > 0. - M. F. Hasler, Oct 16 2018

Examples

			-1 in base -10 is represented as 19 (1*(-10) + 9 = -1), so a(1) = 19;
-11 in base -10 is represented as 29 (2*(-10) + 9 = -11), so a(11) = 29;
-99 in base -10 is represented as 1901 (1*(-10)^3 + 9*(-10)^2 + 1 = -99), so a(99) = 1901.
		

Crossrefs

Cf. A039724 (nonnegative numbers in base -2), A212529 (negative numbers in base -2), A007608 (nonnegative numbers in base -4), A212526 (negative numbers in base -4), A039723 (nonnegative numbers in base -10).

Programs

A212542 Base 2i representation of negative integers.

Original entry on oeis.org

103, 102, 101, 100, 203, 202, 201, 200, 303, 302, 301, 300, 1030003, 1030002, 1030001, 1030000, 1030103, 1030102, 1030101, 1030100, 1030203, 1030202, 1030201, 1030200, 1030303, 1030302, 1030301, 1030300, 1020003, 1020002, 1020001, 1020000, 1020103, 1020102, 1020101, 1020100, 1020203, 1020202, 1020201, 1020200, 1020303
Offset: 1

Views

Author

Joerg Arndt, May 20 2012

Keywords

Comments

Omitting digits for odd powers of 2i (all 0's for the imaginary parts) (e.g. 1030003 --> 1303) gives A212526 (negative integers in base -4).

Examples

			a(13) = 1030003: 1*(2*i)^6 + 0 + 3*(2*i)^4 + 0 + 0 + 0 + 3*(2*i)^0 = -64 + 48 + 3 = -13.
		

Crossrefs

Cf. A212494 (base 2i representation of nonnegative integers).

Programs

  • Maple
    a:= proc(n) local d, i, l, m;
          m:= n; l:= NULL;
          for i from 0 while m>0 do
            d:= irem(m, 4, 'm');
            if irem(i, 2)=0 and d>0 then d:= 4-d; m:= m+1 fi;
            l:= d, 0, l
          od; parse(cat(l))/10
        end:
    seq(a(n), n=1..60); # Alois P. Heinz, May 20 2012

A320636 Negative numbers in base -3.

Original entry on oeis.org

12, 11, 10, 22, 21, 20, 1202, 1201, 1200, 1212, 1211, 1210, 1222, 1221, 1220, 1102, 1101, 1100, 1112, 1111, 1110, 1122, 1121, 1120, 1002, 1001, 1000, 1012, 1011, 1010, 1022, 1021, 1020, 2202, 2201, 2200, 2212, 2211, 2210, 2222, 2221, 2220, 2102, 2101, 2100, 2112
Offset: 1

Views

Author

Jianing Song, Oct 18 2018

Keywords

Comments

Extend A073785 to negative-indexed terms, then a(n) = A073785(-n).

Examples

			-7 in base -3 is represented as 1202 (1*(-3)^3 + 2*(-3)^2 + 2 = -7), so a(7) = 1202;
-16 in base -3 is represented as 1102 (1*(-3)^3 + 1*(-3)^2 + 2 = -16), so a(16) = 1102;
-40 in base -3 is represented as 2222 (2*(-3)^3 + 2*(-3)^2 + 2*(-3) + 2 = -99), so a(40) = 2222.
		

Crossrefs

Nonnegative numbers in negative bases: A039723 (b=-10), A039724 (b=-2), A073785 (b=-3), A007608 (b=-4), A073786 (b=-5), A073787 (b=-6), A073788 (b=-7), A073789 (b=-8), A073790 (b=-9).
Negative numbers in negative bases: A305238 (b=-10), A212529 (b=-2), this sequence (b=-3), A212526 (b=-4).

Programs

A360034 Binary representation of -n in base i-1.

Original entry on oeis.org

0, 11101, 11100, 10001, 10000, 11001101, 11001100, 11000001, 11000000, 11011101, 11011100, 11010001, 11010000, 1110100001101, 1110100001100, 1110100000001, 1110100000000, 1110100011101, 1110100011100, 1110100010001, 1110100010000, 1110111001101, 1110111001100, 1110111000001
Offset: 0

Views

Author

Jianing Song, Jan 22 2023

Keywords

Comments

Note that each Gaussian integer has one and only one base-(i-1) representation.
Also binary representation of -n in base -1-i.
Write out -n in base -4 (A212526), then change each digit 0, 1, 2, 3 to 0000, 0001, 1100, 1101 respectively.

Examples

			a(1) = 11101 since -1 = (i-1)^4 + (i-1)^3 + (i-1)^2 + (i-1)^0. Also, the base-(-4) representation of -1 is 13_(-4), so changing 1 to 0001 and 3 to 1101 yields 11101.
a(5) = 11001101 since -5 = (i-1)^7 + (i-1)^6 + (i-1)^3 + (i-1)^2 + (i-1)^0. Also, the base-(-4) representation of -5 is 23_(-4), so changing 2 to 1100 and 3 to 1101 yields 11001101.
		

Crossrefs

This is A256441 converted from base 10 to base 2. Cf. also A271472.

Programs

  • PARI
    a(n) = my(v = [-n,0], x=0, digit=0, a, b); while(v!=[0,0], a=v[1]; b=v[2]; v[1]=-2*(a\2)+b; v[2]=-(a\2); x+=(a%2)*10^digit; digit++); x \\ Jianing Song, Jan 22 2023; [a,b] represents the number a + b*(-1+i)

Formula

For n >= 1, a(4*n-0..3) = 10000 * A271472(n) + 0, 1, 1100, 1101 respectively.
Showing 1-7 of 7 results.