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

A256702 Nonpositive part of the minimal alternating binary representation of n (defined at A256696).

Original entry on oeis.org

0, 0, 1, 0, 4, 2, 1, 0, 8, 8, 9, 4, 4, 2, 1, 0, 16, 16, 17, 16, 20, 18, 17, 8, 8, 8, 9, 4, 4, 2, 1, 0, 32, 32, 33, 32, 36, 34, 33, 32, 40, 40, 41, 36, 36, 34, 33, 16, 16, 16, 17, 16, 20, 18, 17, 8, 8, 8, 9, 4, 4, 2, 1, 0, 64, 64, 65, 64, 68, 66, 65, 64, 72
Offset: 1

Views

Author

Clark Kimberling, Apr 09 2015

Keywords

Examples

			R(1) = 1; positive part 1, nonpositive part 0.
R(2) = 2; positive part 2, nonpositive part 0.
R(3) = 4 - 1; positive part 4, nonpositive part 1.
R(11) = 16 - 8 + 4 - 1; positive part 16 + 4 = 20; nonpositive part 8 + 1 = 9.
		

Crossrefs

Programs

  • Mathematica
    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]; Take[g, 100]; r[0] = {0};
    r[n_] := If[MemberQ[bb, n], {n}, Join[{g[[n]]}, -r[g[[n]] - n]]]
    Table[Total[Abs[r[n]]], {n, 1, 100}] (* A073122 *)
    u = Table[Total[(Abs[r[n]] + r[n])/2], {n, 1, 100}]  (* A256701 *)
    v = Table[Total[(Abs[r[n]] - r[n])/2], {n, 1, 100}]  (* A256702 *)

Formula

A256701(n) - A256702(n) = n.

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

Original entry on oeis.org

0, 1, 2, 3, 5, -1, 5, 8, -2, 8, -1, 8, 13, -5, 1, 13, -3, 13, -2, 13, -1, 13, 21, -8, 1, 21, -8, 2, 21, -5, 21, -5, 1, 21, -3, 21, -2, 21, -1, 21, 34, -13, 1, 34, -13, 2, 34, -13, 3, 34, -13, 5, -1, 34, -8, 34, -8, 1, 34, -8, 2, 34, -5, 34, -5, 1, 34, -3, 34
Offset: 0

Views

Author

Clark Kimberling, Apr 08 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 introduced here as the minimal alternating b-representation of n. The sum B(n) + B(m(2)) + ... we call 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) = F(n+2), where F = A000045, then the sum is the minimal alternating Fibonacci-representation of n.

Examples

			R(0) = 0
R(1) = 1
R(2) = 2
R(3) = 3
R(4) = 5 - 1
R(9) = 13 - 5 + 1
R(25) = 34 - 13 + 5 - 1
R(64) = 89 - 34 + 13 - 5 + 1
		

Crossrefs

Cf. A000045, A255973 (trace), A256656 (numbers with positive trace), A256657 (numbers with nonpositive trace), A256663 (positive part of R(n)), A256664 (nonpositive part of R(n)), A256654, A256696 (minimal alternating binary representations), A255974 (minimal alternating triangular-number representations), A256789 (minimal alternating squares representations).

Programs

  • Mathematica
    f[n_] = Fibonacci[n]; ff = Table[f[n], {n, 1, 70}];
    s[n_] := Table[f[n + 2], {k, 1, f[n]}];
    h[0] = {1}; h[n_] := Join[h[n - 1], s[n]];
    g = h[12]; r[0] = {0};
    r[n_] := If[MemberQ[ff, n], {n}, Join[{g[[n]]}, -r[g[[n]] - n]]];
    Flatten[Table[r[n], {n, 0, 60}]]

Formula

R(F(k)^2) = F(2k-1) - F(2k-3) + F(2k-5) - ... + d*F(5) + (-1)^k, where d = (-1)^(k+1).

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

Original entry on oeis.org

0, 1, 4, -2, 4, -1, 4, 9, -4, 9, -4, 1, 9, -4, 2, 9, -1, 9, 16, -9, 4, -1, 16, -9, 4, 16, -4, 16, -4, 1, 16, -4, 2, 16, -1, 16, 25, -9, 1, 25, -9, 4, -2, 25, -9, 4, -1, 25, -9, 4, 25, -4, 25, -4, 1, 25, -4, 2, 25, -1, 25, 36, -16, 9, -4, 1, 36, -9, 36, -9, 1
Offset: 0

Views

Author

Clark Kimberling, Apr 13 2015

Keywords

Comments

Let B(n) be the least square >= n. The minimal alternating squares representation of a nonnegative integer n is defined as the sum B(n) - B(m(1)) + B(m(2)) + ... + d*B(m(k)) that results from the recurrence R(n) = B(n) - R(B(n) - n), with initial representations R(0) = 0, R(1) = 1, and R(2) = 4 - 2. The sum B(n) + B(m(2)) + ... is the positive part of R(n), and the sum B(m(1)) + B(m(3)) + ... is the nonpositive part of R(n). The last term of R(k) is the trace of n. If b(n) = n*(n+1)/2, the n-th triangular number, then the sum R(n) is the minimal alternating triangular-number representation of n.
Unlike minimal alternating representations for other bases (e.g., Fibonacci numbers, A256655; binary, A256696, triangular numbers, A244974), the trace of a minimal alternating squares representation is not necessarily a member of the base; specifically, the trace can be -2 or 2, which are not squares.

Examples

			R(0) = 0
R(1) = 1
R(2) = 4 - 2
R(3) = 4 - 1
R(4) = 4
R(5) = 9 - 4
R(6) = 9 - 4 + 1
R(7) = 9 - 4 + 2
R(89) = 100 - 16 + 9 - 4
		

Crossrefs

Cf. A000290, A256655, A256696, A244974, A256790 (number of terms), A256791 (trace).

Programs

  • Mathematica
    b[n_] := n^2; bb = Table[b[n], {n, 0, 1000}];
    s[n_] := Table[b[n], {k, 1, 2 n - 1}];
    h[1] = {1}; h[n_] := Join[h[n - 1], s[n]];
    g = h[100]; r[0] = {0}; r[1] = {1}; r[2] = {4, -2};
    r[n_] := If[MemberQ[bb, n], {n}, Join[{g[[n]]}, -r[g[[n]] - n]]];
    Table[r[n], {n, 0, 120}]  (* A256789, individual representations *)
    Flatten[Table[r[n], {n, 0, 120}]] (* A256789, concatenated representations *)

A055975 First differences of A003188 (decimal equivalent of the Gray Code).

Original entry on oeis.org

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

Views

Author

Alford Arnold, Jul 22 2000

Keywords

Comments

Multiplicative with a(2^e) = 2^e, a(p^e) = (-1)^((p^e-1)/2) otherwise. - Mitch Harris, May 17 2005
a(A091072(n)) > 0; a(A091067(n)) < 0. - Reinhard Zumkeller, Apr 28 2012
In the binary representation of n, clear everything left of the least significant 1 bit, and negate if the bit left of it was set originally. - Ralf Stephan, Aug 23 2013
This sequence is the trace of n in the minimal alternating binary representation of n (defined at A256696). - Clark Kimberling, Apr 07 2015

Examples

			Since A003188 is 0, 1,  3, 2, 6,  7,  5, 4, 12, 13, 15, 14, 10, ...,
sequence begins  1, 2, -1, 4, 1, -2, -1, 8,  1,  2, -1,  4, ... .
		

Crossrefs

Cf. A003188, A006519 (unsigned), A007814.
MASKTRANSi transform of A053644 (conjectural).

Programs

  • Haskell
    a055975 n = a003188 n - a003188 (n-1)
    a055975_list = zipWith (-) (tail a003188_list) a003188_list
    -- Reinhard Zumkeller, Apr 28 2012
    
  • Maple
    nmax:=100: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 1 to ceil(nmax/(p+2)) do a((2*n-1)*2^p) := (-1)^(n+1)*2^p od: od: seq(a(n), n=1..nmax); # Johannes W. Meijer, Jan 27 2013
  • Mathematica
    f[n_]:=BitXor[n,Floor[n/2]];Differences[Array[f,120,0]] (* Harvey P. Dale, Jul 18 2011, applying Robert G. Wilson v's program from A003188 *)
  • PARI
    a(n)=((-1)^((n/2^valuation(n,2)-1)/2)*2^valuation(n,2)) \\ Ralf Stephan
    
  • Python
    def A055975(n): return (n^(n>>1))-((n-1)^(n-1>>1)) # Chai Wah Wu, Jun 29 2022

Formula

a(2n) = 2a(n), a(2n+1) = (-1)^n. G.f. sum(k>=0, 2^k*t/(1+t^2), t=x^2^k). a(n) = 2^A007814(n) * (-1)^((n/2^A007814(n)-1)/2). - Ralf Stephan, Oct 29 2003
a((2*n-1)*2^p) = (-1)^(n+1)*2^p, p >= 0. - Johannes W. Meijer, Jan 27 2013

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Sep 05 2000

A255974 R(k), the minimal alternating triangular-number representation of k, concatenated for k = 0, 1, 2,....

Original entry on oeis.org

0, 1, 3, -1, 3, 6, -3, 1, 6, -1, 6, 10, -3, 10, -3, 1, 10, -1, 10, 15, -6, 3, -1, 15, -3, 15, -3, 1, 15, -1, 15, 21, -6, 1, 21, -6, 3, -1, 21, -3, 21, -3, 1, 21, -1, 21, 28, -6, 28, -6, 1, 28, -6, 3, -1, 28, -3, 28, -3, 1, 28, -1, 28, 36, -10, 3, 36, -6, 36
Offset: 0

Views

Author

Clark Kimberling, Apr 11 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) = n(n+1)/2, the n-th triangular number, then the sum R(n) is the minimal alternating triangular-number representation of n.

Examples

			R(0) = 0
R(1) = 1
R(2) = 3 - 1
R(3) = 3
R(4) = 6 - 3 + 1
R(5) = 6 - 1
R(8) = 10 - 3 + 1
R(11) = 15 - 6 + 3 - 1
		

Crossrefs

Cf. A000217, A256655 (Fibonacci based), A256696 (binary), A256789 (squares).

Programs

  • Mathematica
    b[n_] := n (n + 1)/2; bb = Table[b[n], {n, 0, 1000}];
    s[n_] := Table[b[n], {k, 1, n}];
    h[1] = {1}; h[n_] := Join[h[n - 1], s[n]];
    g = h[100]; r[0] = {0};
    r[n_] := If[MemberQ[bb, n], {n}, Join[{g[[n]]}, -r[g[[n]] - n]]]
    t = Table[r[n], {n, 0, 120}]  (* A255974 actual representations *)
    Flatten[t]  (* A255974 sequence *)

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
Showing 1-6 of 6 results.