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

A073122 Minimal reversing binary representation of n. Converting sum of powers of 2 in binary representation of a(n) to alternating sum gives n. See A072339.

Original entry on oeis.org

1, 2, 5, 4, 13, 10, 9, 8, 25, 26, 29, 20, 21, 18, 17, 16, 49, 50, 53, 52, 61, 58, 57, 40, 41, 42, 45, 36, 37, 34, 33, 32, 97, 98, 101, 100, 109, 106, 105, 104, 121, 122, 125, 116, 117, 114, 113, 80, 81, 82, 85, 84, 93, 90, 89, 72, 73, 74, 77, 68, 69, 66, 65, 64, 193
Offset: 1

Views

Author

T. D. Noe, Jul 17 2002

Keywords

Comments

The minimal representation is unique. The number of powers of 2 can be either even or odd. Compare with A065621, in which the number of powers of 2 is odd. The Mathematica program computes the representation for numbers 1 to 2^m. a(0) = 0.
No term has odd part congruent to 3 modulo 4. - Charlie Neder, Oct 28 2018

Examples

			a(11) = 29 because 29 = 16 + 8 + 4 + 1 and 16 - 8 + 4 - 1 = 11.
a(100) = 164 because 100 in binary is 1100100. The two runs of ones correspond to 2^7 - 2^5 and 2^3 - 2^2, but since 2^3 - 2^2 is the last term of the representation, it can be replaced with 2^2. Therefore, a(100) = 2^7 + 2^5 + 2^2. - _Charlie Neder_, Oct 28 2018
		

References

  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1981, Vol. 2 (Second Edition), p. 196, (exercise 4.1. Nr. 27)

Crossrefs

Programs

  • Mathematica
    Needs["DiscreteMath`Combinatorica`"]; sumit[s_List] := Module[{i, ss=0}, Do[If[OddQ[i], ss+=s[[ -i]], ss-=s[[ -i]]], {i, Length[s]}]; ss]; m=7; powers=Table[2^i, {i, 0, m}]; lst=Table[2m, {2^m}]; lst2=Table[0, {2^m}]; Do[t=NthSubset[i, powers]; len=Length[t]; st=sumit[t]; If[len
    				

Formula

a(2n) = 2 * a(n). [Corrected by Sean A. Irvine, Nov 17 2024]
Express n as a sum of terms 2^x - 2^y, x > y, such that each term defines a run of 1's in n's binary expansion. Then a(n) is the sum of all 2^x + 2^y, with the exception that a term 2^(x+1) - 2^x at the end of a representation becomes 2^x. - Charlie Neder, Oct 28 2018

A072219 Any number n can be written uniquely in the form n = 2^k_1 - 2^k_2 + 2^k_3 - ... + 2^k_{2r+1} where the signs alternate, there are an odd number of terms, and k_1 > k_2 > k_3 > ... > k_{2r+1} >= 0; sequence gives number of terms 2r+1.

Original entry on oeis.org

1, 1, 3, 1, 3, 3, 3, 1, 3, 3, 5, 3, 3, 3, 3, 1, 3, 3, 5, 3, 5, 5, 5, 3, 3, 3, 5, 3, 3, 3, 3, 1, 3, 3, 5, 3, 5, 5, 5, 3, 5, 5, 7, 5, 5, 5, 5, 3, 3, 3, 5, 3, 5, 5, 5, 3, 3, 3, 5, 3, 3, 3, 3, 1, 3, 3, 5, 3, 5, 5, 5, 3, 5, 5, 7, 5, 5, 5, 5, 3, 5, 5, 7, 5, 7, 7, 7, 5, 5, 5, 7, 5, 5, 5, 5, 3, 3, 3, 5, 3, 5, 5, 5, 3, 5
Offset: 1

Views

Author

N. J. A. Sloane, Jul 05 2002

Keywords

Comments

2^k_1 is smallest power of 2 that is >= n.
The first Mathematica program computes the sequence for numbers 1 to 2^m. - T. D. Noe, Jul 15 2002
a(A000079(n)) = 1; a(A238246(n)) = 3; a(A238247(n)) = 5; a(A238248(n)) = 7. - Reinhard Zumkeller, Feb 20 2014
Add 1 to every other terms of A005811. - N. J. A. Sloane, Jan 14 2017

Examples

			1=1, 2=2, 3=4-2+1, 4=4, 5=8-4+1, 6=8-4+2, ...
		

References

  • P. Bachmann, Niedere Zahlentheorie (1902, 1910), reprinted Chelsea, NY, 1968, vol. 2, pp. 61-62.

Crossrefs

Programs

  • Haskell
    a072219 = (+ 1) . (* 2) . a033264 . subtract 1
    -- Reinhard Zumkeller, Feb 20 2014
  • Mathematica
    Needs["DiscreteMath`Combinatorica`"]; sumit[s_List] := Module[{i, ss=0}, Do[If[OddQ[i], ss+=s[[i]], ss-=s[[i]]], {i, Length[s]}]; ss]; m=8; powers=Table[2^i, {i, 0, m}]; lst=Table[0, {2^m}]; sets={}; Do[sets=Union[sets, KSubsets[powers, i]], {i, 1, m+1, 2}]; Do[t=sets[[i]]; lst[[sumit[t]]]=Length[t], {i, Length[sets]}]; lst
    (* second program *)
    a[n_] := 2 Count[Split[IntegerDigits[n-1, 2], #1 == 1 && #2 == 0 &], {1, 0} ] + 1; Array[a, 105] (* Jean-François Alcover, Apr 01 2016 *)

Formula

G.f.: 1/(1+x) + (1/(1-x)) * Sum_{r>=0} x^(2^r) / (1+x^(2^(r+1))). - Ramasamy Chandramouli, Dec 22 2012

Extensions

More terms from T. D. Noe, Jul 15 2002

A256696 R(k), the minimal alternating binary representation of k, concatenated for k = 0, 1, 2,....

Original entry on oeis.org

0, 1, 2, 4, -1, 4, 8, -4, 1, 8, -2, 8, -1, 8, 16, -8, 1, 16, -8, 2, 16, -8, 4, -1, 16, -4, 16, -4, 1, 16, -2, 16, -1, 16, 32, -16, 1, 32, -16, 2, 32, -16, 4, -1, 32, -16, 4, 32, -16, 8, -4, 1, 32, -16, 8, -2, 32, -16, 8, -1, 32, -8, 32, -8, 1, 32, -8, 2, 32
Offset: 0

Views

Author

Clark Kimberling, Apr 09 2015

Keywords

Comments

Suppose that b = (b(0), b(1), ... ) is an increasing sequence of positive integers satisfying b(0) = 1 and b(n+1) <= 2*b(n) for n >= 0. Let B(n) be the least b(m) >= n. Let R(0) = 1, and for n > 0, let R(n) = B(n) - R(B(n) - n). The resulting sum of the form R(n) = B(n) - B(m(1)) + B(m(2)) - ... + ((-1)^k)*B(k) is the minimal alternating b-representation of n. The sum B(n) + B(m(2)) + ... is the positive part of R(n), and the sum B(m(1)) + B(m(3)) + ... , the nonpositive part of R(n). The number ((-1)^k)*B(k) is the trace of n.
If b(n) = 2^n, the sum R(n) is the minimal alternating binary representation of n.
A055975 = trace of n, for n >= 1.
A091072 gives the numbers having positive trace.
A091067 gives the numbers having negative trace.
A072339 = number of terms in R(n).
A073122 = sum of absolute values of the terms in R(n).

Examples

			R(0) = 0
R(1) = 1
R(2) = 2
R(3) = 4 - 1
R(4) = 4
R(9) = 8 - 4 + 1
R(11) = 16 - 8 + 4 - 1
		

References

  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, 1981, Vol. 2 (2nd ed.), p. 196, Exercise 27.

Crossrefs

Programs

  • Mathematica
    z = 100; b[n_] := 2^n; bb = Table[b[n], {n, 0, 40}];
    s[n_] := Table[b[n + 1], {k, 1, b[n]}];
    h[0] = {1}; h[n_] := Join[h[n - 1], s[n - 1]];
    g = h[10]; r[0] = {0};
    r[n_] := If[MemberQ[bb, n], {n}, Join[{g[[n]]}, -r[g[[n]] - n]]]
    u = Flatten[Table[r[n], {n, 0, z}]]
Showing 1-3 of 3 results.