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 13 results. Next

A063090 a(n)/(n*n!) is the average number of comparisons needed to find a node in a binary search tree containing n nodes inserted in a random order.

Original entry on oeis.org

1, 6, 34, 212, 1488, 11736, 103248, 1004832, 10733760, 124966080, 1575797760, 21403457280, 311623441920, 4842481190400, 80007869491200, 1400671686758400, 25902542427955200, 504597366114508800, 10328835149402112000
Offset: 1

Views

Author

Rob Arthan, Aug 06 2001

Keywords

Comments

a(n) is the sum over all permutations, p, of {1, ..., n} of the number of comparisons required to find all the entries in the tree formed when the order of insertion is p(1), p(2), ... p(n). To derive the formula given, first group the trees according to the value of k = p(1). For a given k, p determines a permutation of {1, ..., k-1} that gives the structure of the left subtree. By symmetry, the contribution of the right subtrees will be the same as the left subtrees. Now count and simplify.
a(n) mod n is n-2 or 0 depending on whether n is prime or not. - Gary Detlefs, May 28 2012

References

  • D. E. Knuth, The Art of Computer Programming. Addison-Wesley, Reading, MA, Vol. 3, p. 427, C(n).

Crossrefs

Programs

  • Magma
    [Factorial(n)*((2*n+2)*HarmonicNumber(n) - 3*n): n in [1..30]]; // G. C. Greubel, Sep 01 2018
  • Maple
    A[1]:= 1:
    for n from 2 to 30 do A[n]:= (2*n-1)*(n-1)!+(n+1)*A[n-1] od:
    seq(A[n],n=1..30); # Robert Israel, Sep 21 2014
  • Mathematica
    a[n_] := n!*((2*n+2)*HarmonicNumber[n] - 3*n); Table[a[n], {n, 1, 20}] (* Jean-François Alcover, Sep 20 2012, after Gary Detlefs *)
  • PARI
    {h(n) = sum(k=1,n, 1/k)};
    for(n=1,30, print1(n!*(2*(n+1)*h(n) - 3*n), ", ")) \\ G. C. Greubel, Sep 01 2018
    

Formula

a(1) = 1, a(n) = n*n! + 2 * Sum_{k=1}^{n-1} (n-1)!/k! * a(k).
a(n) = (2*n - 1)*(n - 1)! + (n + 1)*a(n-1).
E.g.f.: -(x+2*log(1-x))/(1-x)^2. - Vladeta Jovovic, Sep 15 2003
a(n) = Sum_{k=0..n} |Stirling1(n, k)|*A000337(k). - Vladeta Jovovic, Jul 06 2004
a(n) = 2*(n+1)*abs(Stirling1(n+1, 2))-3*n*n!. - Vladeta Jovovic, Jul 06 2004
a(n) = n!*((2*n+2)*h(n) - 3*n), where h(n) is the n-th harmonic number. - Gary Detlefs, May 28 2012
a(n) = A288964(n) + n!*n (because this sequence and A288964 have the same definition related to quicksort but under slightly different assumptions). - Petros Hadjicostas, May 03 2020

Extensions

More terms from Vladeta Jovovic, Aug 08 2001
Missing brackets in the formula in the name inserted by Rob Arthan, Sep 21 2014

A330852 Numerator of the rational number A(n) that appears in the formula for the n-th cumulant k(n) = (-1)^n*2^n*(A(n) - (n - 1)!*zeta(n)) of the limiting distribution of the number of comparisons in quicksort, for n >= 2, with A(0) = 1 and A(1) = 0.

Original entry on oeis.org

1, 0, 7, 19, 937, 85981, 21096517, 7527245453, 19281922400989, 7183745930973701, 3616944955616896387, 273304346447259998403709, 76372354431694636659849988531, 25401366514997931592208126670898607, 110490677504100075544188675746430710672527, 37160853195949529205295416197788818165029489819
Offset: 0

Views

Author

Petros Hadjicostas, Apr 28 2020

Keywords

Comments

Hennequin conjectured his cumulant formula in his 1989 paper and proved it in his 1991 thesis.
First he calculates the numbers (B(n): n >= 0), with B(0) = 1 and B(0) = 0, given for p >= 0 by the recurrence
Sum_{r=0..p} Stirling1(p+2, r+1)*B(p-r)/(p-r)! + Sum_{r=0..p} F(r)*F(p-r) = 0, where F(r) = Sum_{i=0..r} Stirling1(r+1,i+1)*G(r-i) and G(k) = Sum_{a=0..k} (-1)^a*B(k-a)/(a!*(k-a)!*2^a).
Then A(n) = L_n(B(1),...,B(n)), where L_n(x_1,...,x_n) are the logarithmic polynomials of Bell.
Hoffman and Kuba (2019, 2020) gave an alternative proof of Hennequin's cumulant formula and gave an alternative calculation for the constants (-2)^n*A(n), which they denote by a_n. See also Finch (2020).
The Maple program below is based on Tan and Hadjicostas (1993), where the numbers (A(n): n >= 0) are also tabulated.
The rest of the references give the theory of the limiting distribution of the number of comparisons in quicksort (and for that reason we omit any discussion of that topic).

Examples

			The first few fractions A(n) are
1, 0, 7/4, 19/8, 937/144, 85981/3456, 21096517/172800, 7527245453/10368000, 19281922400989/3810240000, 7183745930973701/177811200000, ...
The first few fractions (-2)^n*A(n) (= a_n in Hoffman and Kuba and in Finch) are
1, 0, 7, -19, 937/9, -85981/108, 21096517/2700, -7527245453/81000, 19281922400989/14883750, -7183745930973701/347287500, ...
		

References

  • Pascal Hennequin, Analyse en moyenne d'algorithmes, tri rapide et arbres de recherche, Ph.D. Thesis, L'École Polytechnique Palaiseau (1991), p. 83.

Crossrefs

Programs

  • Maple
    # Produces the sequence (B(n): n >= 0)
    B := proc(m) option remember: local v, g, f, b:
    if m = 0 then v := 1: end if: if m = 1 then v := 0: end if:
    if 2 <= m then
    g := proc(k) add((-1)^a*B(k - a)/(a!*(k - a)!*2^a), a = 0 .. k): end proc:
    f := proc(r) add(Stirling1(r + 1, i + 1)*g(r - i), i = 0 .. r): end proc:
    b := proc(p) (-1)^p*(add(Stirling1(p + 2, r + 1)*B(p - r)/(p - r)!, r = 1 .. p) + add(f(rr)*f(p - rr), rr = 1 .. p - 1) + 2*(-1)^p*p!*add((-1)^a*B(p - a)/(a!*(p - a)!*2^a), a = 1 .. p) + 2*add(Stirling1(p + 1, i + 1)*g(p - i), i = 1 .. p))/(p - 1): end proc:
    v := simplify(b(m)): end if: v: end proc:
    # Produces the sequence (A(n): n >= 0)
    A := proc(m) option remember: local v:
    if m = 0 then v := 1: end if: if m = 1 then v := 0: end if:
    if 2 <= m then v := -(m - 1)!*add(A(k + 1)*B(m - 1 - k)/(k!*(m - 1 - k)!), k = 0 .. m - 2) + B(m): end if: v: end proc:
    # Produces the sequence of numerators of the A(n)'s
    seq(numer(A(n)), n = 0 .. 15);
  • Mathematica
    B[m_] := B[m] = Module[{v, g, f, b}, If[m == 0, v = 1]; If[m == 1, v = 0]; If[2 <= m, g[k_] := Sum[(-1)^a*B[k - a]/(a!*(k - a)!*2^a), {a, 0, k}]; f[r_] := Sum[StirlingS1[r + 1, i + 1]*g[r - i], {i, 0, r}]; b[p_] := (-1)^p*(Sum[StirlingS1[p + 2, r + 1]*B[p - r]/(p - r)!, {r, 1, p}] + Sum[f[rr]*f[p - rr], {rr, 1, p - 1}] + 2*(-1)^p*p!*Sum[(-1)^a*B[p - a]/(a!*(p - a)!*2^a), {a, 1, p}] + 2*Sum[StirlingS1[p + 1, i + 1]*g[p - i], {i, 1, p}])/(p - 1); v = Simplify[b[m]]]; v];
    A[m_] := A[m] = Module[{v}, If[ m == 0, v = 1]; If[m == 1, v = 0]; If[2 <= m , v = -(m - 1)!*Sum[A[k + 1]*B[m - 1 - k]/(k!*(m - 1 - k)!), {k , 0 , m - 2}] + B[m]]; v];
    Table[Numerator[A[n]], {n, 0, 15}] (* Jean-François Alcover, Aug 17 2020, translated from Maple *)

A330860 Denominator of the rational number A(n) that appears in the formula for the n-th cumulant k(n) = (-1)^n*2^n*(A(n) - (n - 1)!*zeta(n)) of the limiting distribution of the number of comparisons in quicksort, for n >= 2, with A(0) = 1 and A(1) = 0.

Original entry on oeis.org

1, 1, 4, 8, 144, 3456, 172800, 10368000, 3810240000, 177811200000, 9957427200000, 75278149632000000, 1912817782149120000000, 53023308921173606400000000, 17742659631203112173568000000000, 426249654980023566857797632000000000, 9600207854287580784554747166720000000000
Offset: 0

Views

Author

Petros Hadjicostas, Apr 28 2020

Keywords

Comments

Hennequin conjectured his cumulant formula in his 1989 paper and proved it in his 1991 thesis.
First he calculates the numbers (B(n): n >= 0), with B(0) = 1 and B(0) = 0, given for p >= 0 by the recurrence
Sum_{r=0..p} Stirling1(p+2, r+1)*B(p-r)/(p-r)! + Sum_{r=0..p} F(r)*F(p-r) = 0, where F(r) = Sum_{i=0..r} Stirling1(r+1,i+1)*G(r-i) and G(k) = Sum_{a=0..k} (-1)^a*B(k-a)/(a!*(k-a)!*2^a).
Then A(n) = L_n(B(1),...,B(n)), where L_n(x_1,...,x_n) are the logarithmic polynomials of Bell.
Hoffman and Kuba (2019, 2020) gave an alternative proof of Hennequin's cumulant formula and gave an alternative calculation for the constants (-2)^n*A(n), which they denote by a_n. See also Finch (2020).
The Maple program given in A330852 is based on Tan and Hadjicostas (1993), where the numbers (A(n): n >= 0) are also tabulated.
For a list of references about the theory of the limiting distribution of the number of comparisons in quicksort, which we do not discuss here, see the ones for sequence A330852.

Examples

			The first few fractions A(n) are
1, 0, 7/4, 19/8, 937/144, 85981/3456, 21096517/172800, 7527245453/10368000, 19281922400989/3810240000, 7183745930973701/177811200000, ...
The first few fractions (-2)^n*A(n) (= a_n in Hoffman and Kuba and in Finch) are
1, 0, 7, -19, 937/9, -85981/108, 21096517/2700, -7527245453/81000, 19281922400989/14883750, -7183745930973701/347287500, ...
		

References

  • Pascal Hennequin, Analyse en moyenne d'algorithmes, tri rapide et arbres de recherche, Ph.D. Thesis, L'École Polytechnique Palaiseau (1991), p. 83.

Crossrefs

Programs

  • Maple
    # The function A is defined in A330852.
    # Produces the sequence of denominators of the A(n)'s.
    seq(denom(A(n)), n = 0 .. 40);

A329001 Numerator of the rational constant term c(n) of the n-th moment mu(n) of the limiting distribution of the number of comparisons in quicksort (for n >= 0).

Original entry on oeis.org

1, 0, 7, -19, 2260, -229621, 74250517, -30532750703, 90558126238639, -37973078754146051, 21284764359226368337, -1770024989560214080011109, 539780360793818428471498394131, -194520883210026428577888559667954807, 911287963487139630688627952818633149408727
Offset: 0

Views

Author

Petros Hadjicostas, Apr 30 2020

Keywords

Comments

Let X_n be the number of comparisons needed to sort a list of n distinct numbers by quicksort. Then E(X_n) = A115107(n)/A096620(n) = -4*n + + 2*(1+n)*HarmonicNumber(n) or E(X_n) = A093418(n)/A096620(n) = -3*n + + 2*(1+n)*HarmonicNumber(n) depending on the assumptions.
Régnier (1989) and Rösler (1991) proved that (X_n - E(X_n))/n converges a.s. (and in other modes of convergence) to a non-degenerate r.v. X. Rösler proved the existence of all moments for X and Tan and Hadjicostas (1995) proved that it has a density w.r.t. to the Lebesgue measure. Fill and Janson (2000, 2002) proved many other properties of the distribution of X.
Hennequin (1989, 1991) calculated moments and cumulants of X. He proved that mu(n) = E(X^n) is a linear combination of a finite number of zeta values at positive integer arguments with rational coefficients plus a rational constant c(n). It is the numerators of this constant term c(n) of mu(n) that we tabulate here, while the denominators are in A330876.
Hennequin (1991) proved that the n-th cumulant of X for n >= 2 is k(n) = (-2)^n*(A(n) - (n-1)!*zeta(n)), where A(n) = A330852(n)/A330860(n) with A(0) = 1 and A(1) = 0. Also, (-2)^n*A(n) = A330875(n)/A330876(n); see Hoffman and Kuba (2019-2020) and Finch (2020).
Actually, Hoffman and Kuba (2019-2020, Proposition 17) express the constants c(n) in terms of "tiered binomial coefficients". Finch (2020) uses their results to write a Mathematica program with which he calculates at least c(2) - c(8). The values c(2) - c(8) have also been calculated indirectly by Ekhad and Zeilberger (2019).
Because moments and cumulants are connected via the relationship mu(n) = Sum_{s=0..n-1} binomial(n-1,s)*k(s+1)*mu(n-1-s) (e.g., see Tan and Hadjicostas (1993)), we easily deduce that c(n) = Sum_{s=0..n-1} binomial(n-1,s)*(-2)^(s+1)*A(s+1)*c(n-1-s) for n >= 1 because c(1) = A(1) = mu(1) = k(1) = 0 and k(n) = (-2)^n*A(n) - (-2)^n*(n-1)!*zeta(n) for n >= 2 and c(n) is the constant term of mu(n).

Examples

			The first few c(n) are {1, 0, 7, -19, 2260/9, -229621/108, 74250517/2700, -30532750703/81000, 90558126238639/14883750, -37973078754146051/347287500, ...}.
		

References

  • Pascal Hennequin, Analyse en moyenne d'algorithmes, tri rapide et arbres de recherche, Ph.D. Thesis, L'École Polytechnique Palaiseau (1991).

Crossrefs

Programs

  • Maple
    # The function A is defined in A330852.
    # Produces the constants c(n):
    c := proc(p) local v, a: option remember:
    if p = 0 then v := 1; end if: if p = 1 then v := 0: end if:
    if 2 <= p then v := (p - 1)!*add((-2)^(a + 1)*A(a + 1)*c(p - 1 - a)/(a!*(p - 1 - a)!), a = 0 .. p - 1): end if:
    v: end proc:
    # Produces the numerators of c(n):
    seq(numer(c(n)), n=0..15);
  • Mathematica
    (* The function A is defined in A330852. *)
    c[p_] := c[p] = Module[{v, a}, If[p == 0, v = 1;]; If[p == 1, v = 0]; If[2 <= p, v = (p - 1)!*Sum[(-2)^(a + 1)*A[a + 1]*c[p - 1 - a]/(a!*(p - 1 - a)!), {a, 0, p - 1}]]; v];
    Table[Numerator[c[n]], {n, 0, 15}] (* Jean-François Alcover, Mar 28 2021, after Maple code *)

Formula

Recurrence for the fractions: c(n) = Sum_{s=0..n-1} binomial(n-1,s)*(-2)^(s+1)*A(s+1)*c(n-1-s) for n >= 1, with c(0) = 1 = A(0) and c(1) = 0 = A(1), where A(n) = A330852(n)/A330860(n) and (-2)^n*A(n) = A330875(n)/A330876(n).

A330876 Denominator of the fraction fr(n) that appears in the n-th cumulant k(n) = fr(n) - (-2)^n*(n-1)!*zeta(n) of the limiting distribution of the number of comparisons in quicksort, for n >= 2, starting with fr(0) = 1 and fr(1) = 0.

Original entry on oeis.org

1, 1, 1, 1, 9, 108, 2700, 81000, 14883750, 347287500, 9724050000, 36756909000000, 466996528845000000, 6472571889791700000000, 1082926002881049327000000000, 13008107146607164515924000000000
Offset: 0

Views

Author

Petros Hadjicostas, Apr 29 2020

Keywords

Comments

Hennequin conjectured his cumulant formula in his 1989 paper and proved it in his 1991 thesis.
First he calculates the numbers (B(n): n >= 0), with B(0) = 1 and B(0) = 0, given for p >= 0 by the recurrence
Sum_{r=0..p} Stirling1(p+2, r+1)*B(p-r)/(p-r)! + Sum_{r=0..p} F(r)*F(p-r) = 0, where F(r) = Sum_{i=0..r} Stirling1(r+1,i+1)*G(r-i) and G(k) = Sum_{a=0..k} (-1)^a*B(k-a)/(a!*(k-a)!*2^a).
Then fr(n) = (-2)^n*L_n(B(1),...,B(n)), where L_n(x_1,...,x_n) are the logarithmic polynomials of Bell.
Hoffman and Kuba (2019, 2020) gave an alternative proof of Hennequin's cumulant formula and gave an alternative calculation for the constants fr(n), which they denote by a_n. See also Finch (2020).
Tan and Hadjicostas (1993) used a Maple program (an update of which can be found in A330852) to tabulate the numbers (fr(n)/(-2)^n: n >= 0).
Sequence A330852 contains additional references that give the theory of the limiting distribution of the number of comparisons in quicksort (and for that reason we omit any discussion of that topic).

Examples

			The first few fractions fr(n) are: 1, 0, 7, -19, 937/9, -85981/108, 21096517/2700, -7527245453/81000, 19281922400989/14883750, -7183745930973701/347287500, ...
		

References

  • Pascal Hennequin, Analyse en moyenne d'algorithmes, tri rapide et arbres de recherche, Ph.D. Thesis, L'École Polytechnique Palaiseau (1991), p. 83.

Crossrefs

Formula

a(n) = denominator((-2)^n*A330852(n)/A330860(n)).

A330875 Numerator of the fraction fr(n) that appears in the n-th cumulant k(p) = fr(n) - (-2)^n*(n-1)!*zeta(n) of the limiting distribution of the number of comparisons in quicksort, for n >= 2, starting with fr(0) = 1 and fr(1) = 0.

Original entry on oeis.org

1, 0, 7, -19, 937, -85981, 21096517, -7527245453, 19281922400989, -7183745930973701, 3616944955616896387, -273304346447259998403709, 76372354431694636659849988531, -25401366514997931592208126670898607, 110490677504100075544188675746430710672527
Offset: 0

Views

Author

Petros Hadjicostas, Apr 29 2020

Keywords

Comments

Hennequin conjectured his cumulant formula in his 1989 paper and proved it in his 1991 thesis.
First he calculates the numbers (B(n): n >= 0), with B(0) = 1 and B(0) = 0, given for p >= 0 by the recurrence
Sum_{r=0..p} Stirling1(p+2, r+1)*B(p-r)/(p-r)! + Sum_{r=0..p} F(r)*F(p-r) = 0, where F(r) = Sum_{i=0..r} Stirling1(r+1,i+1)*G(r-i) and G(k) = Sum_{a=0..k} (-1)^a*B(k-a)/(a!*(k-a)!*2^a).
Then fr(n) = (-2)^n*L_n(B(1),...,B(n)), where L_n(x_1,...,x_n) are the logarithmic polynomials of Bell.
Hoffman and Kuba (2019, 2020) gave an alternative proof of Hennequin's cumulant formula and gave an alternative calculation for the constants fr(n), which they denote by a_n. See also Finch (2020).
Tan and Hadjicostas (1993) used a Maple program (an update of which can be found in A330852) to tabulate the numbers (fr(n)/(-2)^n: n >= 0).
Sequence A330852 contains additional references that give the theory of the limiting distribution of the number of comparisons in quicksort (and for that reason we omit any discussion of that topic).

Examples

			The first few fractions fr(n) are 1, 0, 7, -19, 937/9, -85981/108, 21096517/2700, -7527245453/81000, 19281922400989/14883750, -7183745930973701/347287500, ...
		

References

  • Pascal Hennequin, Analyse en moyenne d'algorithmes, tri rapide et arbres de recherche, Ph.D. Thesis, L'École Polytechnique Palaiseau (1991), p. 83.

Crossrefs

Formula

a(n) = numerator((-2)^n*A330852(n)/A330860(n)).

A330895 Numerator of the variance of the random number of comparisons in quicksort applied to lists of length n.

Original entry on oeis.org

0, 0, 0, 2, 29, 46, 3049, 60574, 160599, 182789, 4913659, 1072364, 975570703, 1039388677, 5491155875, 92211937094, 6954047816459, 7225392149719, 2699717387790739, 2785123121790325, 573031978700759, 84009502802237, 45510401082365873, 46518885869845328
Offset: 0

Views

Author

Petros Hadjicostas, May 01 2020

Keywords

Examples

			The variances are: 0, 0, 0, 2/9, 29/36, 46/25, 3049/900, 60574/11025, 160599/19600, 182789/15876, 4913659/317520, 1072364/53361, ... = A330895/A330907.
		

References

  • D. E. Knuth, The Art of Computer Programming, Volume 3: Sorting and Searching, Addison-Wesley, 1973; see answer to Ex. 8(a) of Section 6.2.2.

Crossrefs

Programs

  • PARI
    lista(nn) = {my(va = vector(nn)); for(n=1, nn, va[n] = numerator(n*(7*n+13) - 2*(n+1)*sum(k=1, n, 1/k) - 4*(n+1)^2*sum(k=1, n, 1/k^2))); concat(0,va);}

Formula

a(n) = numerator(fr(n)), where fr(n) = n*(7*n + 13) - 2*(n + 1)*Sum_{k=1..n} 1/k - 4*(n + 1)^2*Sum_{k=1..n} 1/k^2.

A330907 Denominator of the variance of the random number of comparisons in quicksort applied to lists of length n.

Original entry on oeis.org

1, 1, 1, 9, 36, 25, 900, 11025, 19600, 15876, 317520, 53361, 38419920, 33127380, 144288144, 2029052025, 129859329600, 115831315600, 37529346254400, 33870234994596, 6144260316480, 799769421360, 387088399938240, 355503061748835, 40953952713465792, 37864231428870000, 316002721554520000, 2056839142975402500, 1612561888092715560000
Offset: 0

Views

Author

Petros Hadjicostas, May 01 2020

Keywords

Examples

			The variances are: 0, 0, 0, 2/9, 29/36, 46/25, 3049/900, 60574/11025, 160599/19600, 182789/15876, 4913659/317520, 1072364/53361, ... = A330895/A330907.
		

References

  • D. E. Knuth, The Art of Computer Programming, Volume 3: Sorting and Searching, Addison-Wesley, 1973; see answer to Ex. 8(a) of Section 6.2.2.

Crossrefs

Programs

  • Maple
    a := n -> denom(2*(n+1)*(harmonic(n,1) + 2*(n+1)*harmonic(n,2))):
    seq(a(n), n=0..28); # Peter Luschny, May 02 2020
  • PARI
    lista(nn) = {my(va = vector(nn)); for(n=1, nn, va[n] = denominator(n*(7*n+13) - 2*(n+1)*sum(k=1, n, 1/k) - 4*(n+1)^2*sum(k=1, n, 1/k^2))); concat(1, va); }

Formula

a(n) = denominator(fr(n)), where fr(n) = n*(7*n + 13) - 2*(n+1)*Sum_{k=1..n} (1/k) - 4*(n+1)^2*Sum_{k=1..n} (1/k^2).
a(n) = denominator(2*(n+1)*(H(n,1) + 2*(n+1)*H(n,2))), where H(n,s) are the generalized harmonic numbers. - Peter Luschny, May 02 2020

A078903 a(n) = n^2 - Sum_{u=1..n} Sum_{v=1..u} valuation(2*v, 2).

Original entry on oeis.org

0, 0, 1, 1, 2, 3, 5, 5, 6, 7, 9, 10, 12, 14, 17, 17, 18, 19, 21, 22, 24, 26, 29, 30, 32, 34, 37, 39, 42, 45, 49, 49, 50, 51, 53, 54, 56, 58, 61, 62, 64, 66, 69, 71, 74, 77, 81, 82, 84, 86, 89, 91, 94, 97, 101, 103, 106, 109, 113, 116, 120, 124, 129, 129, 130, 131, 133, 134
Offset: 1

Views

Author

Benoit Cloitre, Dec 12 2002

Keywords

Comments

This is a fractal generator sequence. Let Fr(m,n) = m*n - a(n); then the graph of Fr(m,n) for 1 <= n <= 4^(m+1) - 3 presents fractal aspects.

Examples

			Fr(1, n) for 1 <= n <= 4^2-3 = 13 gives 1, 2, 2, 3, 3, 3, 2, 3, 3, 3, 2, 2, 1.
Fr(2, n) for 1 <= n <= 4^3-3 = 63 gives 2, 4, 5, 7, 8, 9, 9, 11, 12, 13, 13, 14, 14, 14, 13, 15, 16, 17, 17, 18, 18, 18, 17, 18, 18, 18, 17, 17, 16, 15, 13, 15, 16, 17, 17, 18, 18, 18, 17, 18, 18, 18, 17, 17, 16, 15, 13, 14, 14, 14, 13, 13, 12, 11, 9, 9, 8, 7, 5, 4, 2.
		

Crossrefs

Equals (1/2) * A076178(n).

Programs

  • Magma
    [n^2-(&+[ &+[Valuation(2*v,2):v in [1..u]]:u in [1..n]]):n in [1..70]]; //  Marius A. Burtea, Oct 24 2019
    
  • Maple
    a:= proc(n) option remember; `if`(n=0, 0,
          a(n-1)-1+add(i, i=Bits[Split](n)))
        end:
    seq(a(n), n=1..68);  # Alois P. Heinz, Feb 03 2024
  • Mathematica
    Accumulate@Table[DigitCount[n, 2, 1] - 1, {n, 68}] (* Ivan Neretin, Sep 07 2017 *)
  • PARI
    a(n)=n^2-sum(u=1,n,sum(v=1,u,valuation(2*v,2)))
    
  • Python
    def A078903(n): return (n+1)*n.bit_count()-n+(sum((m:=1<>j)-(r if n<<1>=m*(r:=k<<1|1) else 0)) for j in range(1,n.bit_length()+1))>>1)  # Chai Wah Wu, Nov 12 2024

Formula

a(n) = n^2 - Sum_{k=1..n} A005187(k);
a(n) = n^2 - Sum_{u=1..n} Sum_{v=1..u} A001511(v);
a(n+1) - a(n) = A048881(n).
G.f.: 1/(1-x)^2 * ((x(1+x)/(1-x) - Sum_{k>=0} x^2^k/(1-x^2^k))). - Ralf Stephan, Apr 12 2002
a(0) = 0, a(2*n) = a(n) + a(n-1) + n - 1, a(2*n+1) = 2*a(n) + n. Also, a(n) = A000788(n) - n. - Ralf Stephan, Oct 05 2003

A076178 a(n) = 2*n^2 - A077071(n).

Original entry on oeis.org

0, 0, 0, 2, 2, 4, 6, 10, 10, 12, 14, 18, 20, 24, 28, 34, 34, 36, 38, 42, 44, 48, 52, 58, 60, 64, 68, 74, 78, 84, 90, 98, 98, 100, 102, 106, 108, 112, 116, 122, 124, 128, 132, 138, 142, 148, 154, 162, 164, 168, 172, 178, 182, 188, 194, 202, 206, 212, 218, 226, 232
Offset: 0

Views

Author

Benoit Cloitre, Nov 01 2002

Keywords

Crossrefs

Equals 2 * A078903(n).

Programs

  • PARI
    a(n)=2*n^2-sum(k=0,n,-valuation(polcoeff(pollegendre(2*n),2*k),2))
    
  • Python
    def A076178(n): return ((n+1)*n.bit_count()-n<<1)+sum((m:=1<>j)-(r if n<<1>=m*(r:=k<<1|1) else 0)) for j in range(1,n.bit_length()+1)) # Chai Wah Wu, Nov 12 2024

Formula

a(n) = A001105(n) - A077071(n). - Omar E. Pol, Nov 13 2024
Showing 1-10 of 13 results. Next