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.

A004718 The Danish composer Per Nørgård's "infinity sequence", invented in an attempt to unify in a perfect way repetition and variation: a(2n) = -a(n), a(2n+1) = a(n) + 1, a(0) = 0.

Original entry on oeis.org

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

Views

Author

Jorn B. Olsson (olsson(AT)math.ku.dk)

Keywords

Comments

Minima are at n=2^i-2, maxima at 2^i-1, zeros at A083866.
a(n) has parity of Thue-Morse sequence on {0,1} (A010060).
a(n) = A000120(n) for all n in A060142.
The composer Per Nørgård's name is also written in the OEIS as Per Noergaard.
Comment from Michael Nyvang on the "iris" score on the "Voyage into the golden screen" video, Dec 31 2018: That is A004718 on the cover in the 12-tone tempered chromatic scale. The music - as far as I recall - is constructed from this base by choosing subsequences out of this sequence in what Per calls 'wave lengths', and choosing different scales modulo (to-tone, overtones on one fundamental, etc). There quite a lot more to say about this, but I believe this is the foundation. - N. J. A. Sloane, Jan 05 2019
From Antti Karttunen, Mar 09 2019: (Start)
This sequence can be represented as a binary tree. After a(0) = 0 and a(1) = 1, each child to the left is obtained by negating the parent node's contents, and each child to the right is obtained by adding one to the parent's contents:
0
|
...................1...................
-1 2
1......../ \........0 -2......../ \........3
/ \ / \ / \ / \
/ \ / \ / \ / \
/ \ / \ / \ / \
-1 2 0 1 2 -1 -3 4
1 0 -2 3 0 1 -1 2 -2 3 1 0 3 -2 -4 5
etc.
Sequences A323907, A323908 and A323909 are in bijective correspondence with this sequence and their terms are all nonnegative.
(End)

Crossrefs

Cf. A083866 (indices of 0's), A256187 (first differences), A010060 (mod 2), A343029, A343030.

Programs

  • Haskell
    import Data.List (transpose)
    a004718 n = a004718_list !! n
    a004718_list = 0 : concat
       (transpose [map (+ 1) a004718_list, map negate $ tail a004718_list])
    -- Reinhard Zumkeller, Mar 19 2015, Nov 10 2012
    
  • Maple
    f:=proc(n) option remember; if n=0 then RETURN(0); fi; if n mod 2 = 0 then RETURN(-f(n/2)); else RETURN(f((n-1)/2)+1); fi; end;
  • Mathematica
    a[n_?EvenQ] := a[n]= -a[n/2]; a[0]=0; a[n_] := a[n]= a[(n-1)/2]+1; Table[a[n], {n, 0, 85}](* Jean-François Alcover, Nov 18 2011 *)
    Table[Fold[If[#2 == 0, -#1, #1 + 1] &, IntegerDigits[n, 2]], {n, 0, 85}] (* Michael De Vlieger, Jun 30 2016 *)
  • PARI
    a=vector(100); a[1]=1; a[2]=-1; for(n=3,#a,a[n]=if(n%2,a[n\2]+1,-a[n\2])); a \\ Charles R Greathouse IV, Nov 18 2011
    
  • PARI
    apply( {A004718(n)=[n=if(b,n+1,-n)|b<-binary(n+n=0)];n}, [0..77]) \\ M. F. Hasler, Jun 13 2025
    
  • Python
    # from first formula
    from functools import reduce
    def f(s, b): return s + 1 if b == '1' else -s
    def a(n): return reduce(f, [0] + list(bin(n)[2:]))
    print([a(n) for n in range(86)]) # Michael S. Branicky, Apr 03 2021
    
  • Python
    # via recursion
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def a(n): return 0 if n == 0 else (a((n-1)//2)+1 if n%2 else -a(n//2))
    print([a(n) for n in range(86)]) # Michael S. Branicky, Apr 03 2021
    
  • Python
    from itertools import groupby
    def A004718(n):
        c = 0
        for k, g in groupby(bin(n)[2:]):
            c = c+len(list(g)) if k == '1' else (-c if len(list(g))&1 else c)
        return c # Chai Wah Wu, Mar 02 2023

Formula

Write n in binary and read from left to right, starting with 0 and interpreting 1 as "add 1" and 0 as "change sign". For example 19 = binary 10011, giving 0 -> 1 -> -1 -> 1 -> 2 -> 3, so a(19) = 3.
G.f.: sum{k>=0, x^(2^k)/[1-x^(2*2^k)] * prod{l=0, k-1, x^(2^l)-1}}.
The g.f. satisfies F(x^2)*(1-x) = F(x)-x/(1-x^2).
a(n) = (2 * (n mod 2) - 1) * a(floor(n/2)) + n mod 2. - Reinhard Zumkeller, Mar 20 2015
Zumkeller's formula implies that a(2n) = -a(n), and so a(n) = a(4n) = a(16n) = .... - N. J. A. Sloane, Dec 31 2018
From Kevin Ryde, Apr 17 2021: (Start)
a(n) = (-1)^t * (t+1 - a(n-1)) where t = A007814(n) is the 2-adic valuation of n.
a(n) = A343029(n) - A343030(n). (End)
-(log_2(n+2)-1) <= a(n) <= log_2(n+1). - Charles R Greathouse IV, Nov 15 2022

Extensions

Edited by Ralf Stephan, Mar 07 2003

A323365 Sum of Stern's Diatomic sequence, A002487 and its Dirichlet inverse, A317843.

Original entry on oeis.org

2, 0, 0, 1, 0, 4, 0, 1, 4, 6, 0, 2, 0, 6, 12, 1, 0, 4, 0, 3, 12, 10, 0, 2, 9, 10, 8, 3, 0, -4, 0, 1, 20, 10, 18, 4, 0, 14, 20, 3, 0, 4, 0, 5, 4, 14, 0, 2, 9, 5, 20, 5, 0, 8, 30, 3, 28, 14, 0, 4, 0, 10, 20, 1, 30, -8, 0, 5, 28, 0, 0, 4, 0, 22, -2, 7, 30, 0, 0, 3, 16, 22, 0, 8, 30, 26, 28, 5, 0, 20, 30, 7, 20, 18, 42, 2, 0, 9, 4, 7, 0, 4, 0, 5, 0
Offset: 1

Views

Author

Antti Karttunen, Jan 13 2019

Keywords

Crossrefs

Cf. A002487 (also a quadrisection of this sequence), A317843.

Programs

Formula

a(n) = A002487(n) + A317843(n).
From Antti Karttunen, Dec 08 2021: (Start)
a(1) = 2, and for n > 1, a(n) = -Sum_{d|n, 1A002487(d) * A317843(n/d).
a(4*n) = A002487(n).
(End)

A323882 Sum of A126760 and its Dirichlet inverse.

Original entry on oeis.org

2, 0, 0, 1, 0, 2, 0, 1, 1, 4, 0, 1, 0, 6, 4, 1, 0, 1, 0, 2, 6, 8, 0, 1, 4, 10, 1, 3, 0, 0, 0, 1, 8, 12, 12, 1, 0, 14, 10, 2, 0, 0, 0, 4, 2, 16, 0, 1, 9, 14, 12, 5, 0, 1, 16, 3, 14, 20, 0, 2, 0, 22, 3, 1, 20, 0, 0, 6, 16, 12, 0, 1, 0, 26, 14, 7, 24, 0, 0, 2, 1, 28, 0, 3, 24, 30, 20, 4, 0, 2, 30, 8, 22, 32, 28, 1, 0, 25, 4, 9, 0, 0, 0, 5, 12
Offset: 1

Views

Author

Antti Karttunen, Feb 08 2019

Keywords

Comments

From Antti Karttunen, Aug 18 2021: (Start)
No negative terms in range 1 .. 2^20.
Apparently zeros occur only on (some of the) positions given by A030059, with exceptions for example on n = 70, 105, 110, 130, 154, etc, where a(n) > 0.
(End)

Crossrefs

Programs

  • PARI
    up_to = 20000;
    A126760(n) = {n&&n\=3^valuation(n, 3)<A126760
    DirInverseCorrect(v) = { my(u=vector(#v)); u[1] = (1/v[1]); for(n=2, #v, u[n] = (-u[1])*sumdiv(n, d, if(dA126760(n)));
    A323881(n) = v323881[n];
    A323882(n) = (A126760(n)+A323881(n));

Formula

a(n) = A126760(n) + A323881(n).
For n > 1, a(n) = -Sum_{d|n, 1A126760(d) * A323881(n/d). - Antti Karttunen, Aug 18 2021

A323885 Sum of A001511 and its Dirichlet inverse.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Feb 08 2019

Keywords

Crossrefs

Programs

  • PARI
    A001511(n) = (1+valuation(n,2));
    A092673(n) = (moebius(n)-if(n%2,0,moebius(n/2)));
    A323885(n) = (A001511(n)+A092673(n));
    
  • Python
    from sympy import mobius
    def A323885(n): return (n&-n).bit_length()+mobius(n)-(0 if n&1 else mobius(n>>1)) # Chai Wah Wu, Jul 13 2022

Formula

a(n) = A001511(n) + A092673(n).

A323896 Sum of binary Gray code A003188 and its Dirichlet inverse, A323895.

Original entry on oeis.org

2, 0, 0, 9, 0, 12, 0, 9, 4, 42, 0, 0, 0, 24, 28, 27, 0, 62, 0, -15, 16, 84, 0, 33, 49, 66, 44, -6, 0, -74, 0, 45, 56, 150, 56, -4, 0, 156, 44, 123, 0, 118, 0, -36, 130, 168, 0, 24, 16, -105, 100, -27, 0, -62, 196, 69, 104, 114, 0, 230, 0, 96, 180, 99, 154, 46, 0, -69, 112, 42, 0, 186, 0, 330, -98, -72, 112, 118, 0, 39, 117, 366, 0, 47
Offset: 1

Views

Author

Antti Karttunen, Feb 08 2019

Keywords

Crossrefs

Programs

  • PARI
    up_to = 65537;
    DirInverse(v) = { my(u=vector(#v)); u[1] = (1/v[1]); for(n=2, #v, u[n] = -sumdiv(n, d, if(dA003188(n) = bitxor(n, n>>1);
    v323895 = DirInverse(vector(up_to,n,A003188(n)));
    A323895(n) = v323895[n];
    A323896(n) = (A003188(n)+A323895(n));

Formula

a(n) = A003188(n) + A323895(n).

A323886 Dirichlet inverse of A004718, Per Nørgård's "infinity sequence".

Original entry on oeis.org

1, 1, -2, 0, 0, -2, -3, 0, 2, 0, -1, 0, 1, -3, -4, 0, 0, 2, -3, 0, 11, -1, -2, 0, -3, 1, 0, 0, 2, -4, -5, 0, 2, 0, -1, 0, 1, -3, -8, 0, -1, 11, -2, 0, 16, -2, -3, 0, 10, -3, -4, 0, -2, 0, -1, 0, 8, 2, 1, 0, 3, -5, -26, 0, 0, 2, -3, 0, 7, -1, -2, 0, -3, 1, 12, 0, 8, -8, -5, 0, -5, -1, -2, 0, 0, -2, -11, 0, -2, 16, -7, 0, 21, -3, -4, 0, -3, 10, 0, 0, 2, -4, -5, 0
Offset: 1

Views

Author

Antti Karttunen, Feb 08 2019

Keywords

Comments

The composer Per Nørgård's name is also written in the OEIS as Per Noergaard.

Crossrefs

Programs

  • Mathematica
    b[0] = 0;
    b[n_?EvenQ] := b[n] = -b[n/2];
    b[n_] := b[n] = b[(n - 1)/2] + 1;
    a[n_] := a[n] = If[n == 1, 1, -Sum[b[n/d] a[d], {d, Most@ Divisors[n]}]];
    Array[a, 100] (* Jean-François Alcover, Feb 16 2020 *)
  • PARI
    up_to = 65537;
    A004718list(up_to) = { my(v=vector(up_to)); v[1]=1; v[2]=-1; for(n=3, up_to, v[n] = if(n%2, v[n>>1]+1, -v[n/2])); (v); }; \\ After code in A004718.
    DirInverseCorrect(v) = { my(u=vector(#v)); u[1] = (1/v[1]); for(n=2, #v, u[n] = (-u[1])*sumdiv(n, d, if(dA004718list(up_to));
    A323886(n) = v323886[n];
Showing 1-6 of 6 results.