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.

User: Sen-peng Eu

Sen-peng Eu's wiki page.

Sen-peng Eu has authored 13 sequences. Here are the ten most recent ones:

A335966 a(n) is the number of odd terms in the n-th row of triangle A056939.

Original entry on oeis.org

1, 2, 2, 2, 2, 6, 2, 2, 2, 4, 4, 4, 4, 14, 2, 2, 2, 4, 4, 4, 4, 12, 4, 4, 4, 8, 8, 8, 8, 30, 2, 2, 2, 4, 4, 4, 4, 12, 4, 4, 4, 8, 8, 8, 8, 28, 4, 4, 4, 8, 8, 8, 8, 24, 8, 8, 8, 16, 16, 16, 16, 62, 2, 2, 2, 4, 4, 4, 4, 12, 4, 4, 4, 8, 8, 8, 8, 28, 4, 4, 4, 8, 8, 8, 8, 24
Offset: 0

Author

Sen-Peng Eu, Jul 01 2020

Keywords

Comments

The entries of Baxter triangles are binomial(n+1, k-1)*binomial(n+1, k)*binomial(n+1, k+1)/(binomial(n+1, 1)*binomial(n+1, 2)).

Examples

			a(4)=2 as there are two odd numbers among 1,10,10,1.
		

Crossrefs

Cf. A056939.

Programs

  • Mathematica
    a[n_] := Count[Table[2 * Binomial[n, k] * Binomial[n + 1, k + 1] * Binomial[n + 2, k + 2]/((n - k + 1)^2 * (n - k + 2)), {k, 0, n}], ?OddQ]; Array[a, 100, 0] (* _Amiram Eldar, Jul 02 2020 *)
  • PARI
    T(n,m) = 2*binomial(n, m)*binomial(n + 1, m + 1)*binomial(n + 2, m + 2)/(( n - m + 1)^2*(n - m + 2)); \\ A056939
    a(n) = sum(m=0, n, T(n,m) % 2); \\ Michel Marcus, Jul 02 2020

Formula

a(n) is even if n>=1.
a(n) = n iff n is of the form 2^k-2.
a(2^k-3) = 2^k-2.

A335965 a(n) = number of odd numbers in the n-th row of the Narayana triangle A001263.

Original entry on oeis.org

1, 2, 3, 2, 2, 4, 7, 2, 2, 4, 6, 4, 4, 8, 15, 2, 2, 4, 6, 4, 4, 8, 14, 4, 4, 8, 12, 8, 8, 16, 31, 2, 2, 4, 6, 4, 4, 8, 14, 4, 4, 8, 12, 8, 8, 16, 30, 4, 4, 8, 12, 8, 8, 16, 28, 8, 8, 16, 24, 16, 16, 32, 63, 2, 2, 4, 6, 4, 4, 8, 14, 4, 4, 8, 12, 8, 8, 16, 30, 4, 4, 8
Offset: 1

Author

Sen-Peng Eu, Jul 01 2020

Keywords

Comments

a(n)=n iff n=2^k-1 or n=2.

Examples

			The Narayana numbers are binomial(n-1, k-1)*binomial(n, k-1)/k. a(4)=4 since for n=4 there are two odd numbers among 1,6,6,1.
		

Crossrefs

Cf. A001263.

Programs

A335009 Irregular triangle read by rows: T(n,k) is the number of permutations of two copies of 1..n with the sum of the distances between equal numbers having total value n + 2*k, 0 <= k <= n*(n-1)/2.

Original entry on oeis.org

1, 2, 4, 6, 24, 24, 36, 24, 144, 288, 480, 576, 432, 576, 120, 960, 2880, 6000, 10560, 12960, 18720, 18000, 17280, 11520, 14400, 720, 7200, 28800, 74880, 161280, 269280, 423360, 596160, 725760, 876960, 915840, 967680, 794880, 691200, 432000, 518400
Offset: 1

Author

Sen-peng Eu, May 19 2020

Keywords

Comments

For the n-th row, the least possible sum of distances is n and the corresponding number of permutations is n!.
For the n-th row, the greatest possible sum of distances is n^2 and the corresponding number of permutations is (n!)^2.

Examples

			For the 6 permutations of [1,1,2,2], there are 2 with total distance 2: [1,1,2,2] and [2,2,1,1]. the other 4 have total distances 4. Hence row 2 of the triangle is 2, 4.
For [1,1,2,2,3,3], there are 6, 24, 24, 36 permutations having total distances 3, 5, 7, 9 respectively. Hence row 3 of the triangle is 6, 24, 24, 36.
Triangle begins:
   1;
   2,   4;
   6,  24,  24,  36;
  24, 144, 288, 480, 576, 432, 576;
  ...
		

Crossrefs

Cf. A000142 (1st column), A001044 (right diagonal), A000124 (row sizes).

Programs

  • Mathematica
    totD[w_] := -Sum[ Subtract @@ Flatten@ Position[w, k], {k, Length[w]/2}]; row[n_] := Last /@ Tally@ Sort[totD /@ Permutations[ Flatten[ Table[{i, i}, {i, n}]]]]; Flatten[row /@ Range[5]] (* Giovanni Resta, May 19 2020 *)
  • PARI
    Row(n)={my(v=vector(1+n*(n-1)/2)); forperm(vector(2*n,i,(i+1)\2), p, my(u=vecsort(Vec(p), ,1), s=sum(i=1, n, abs(u[2*i]-u[2*i-1]-1))); v[1+s/2]++); v} \\ Andrew Howroyd, Aug 11 2020

Formula

T(n,0) = n!.
T(n,n*(n-1)/2) = n!^2.

Extensions

More terms from Giovanni Resta, May 19 2020

A335012 Number of different remainders when the first n terms of 1, 11, 111, 1111, ... are divided by n.

Original entry on oeis.org

1, 1, 3, 2, 1, 3, 6, 3, 9, 1, 2, 4, 6, 6, 3, 4, 16, 9, 18, 2, 6, 2, 22, 5, 2, 6, 27, 7, 28, 3, 15, 5, 6, 16, 6, 10, 3, 18, 6, 3, 5, 6, 21, 3, 9, 22, 46, 6, 42, 2, 48, 7, 13, 27, 2, 8, 18, 28, 58, 4, 60, 15, 18, 6, 6, 6, 33, 17, 66, 6, 35, 11, 8, 3, 4, 19, 6, 6, 13, 4, 81
Offset: 1

Author

Sen-Peng Eu, May 19 2020

Keywords

Comments

a(n) = n if and only if n is a power of 3.
Conjecture: a(n) = n-1 if and only if n is a long period prime (A006883), that is, n is a prime and the decimal expansion of 1/n has period n-1.
If gcd(n,30) = 1 then a(n) = A084680(n). - Robert Israel, Jun 25 2020

Examples

			a(4) = 2 since when 1, 11, 111, 1111 are divided by 4 the remainders are 1, 3, 3, 3, two different numbers.
a(6) = 3 since when 1, 11, 111, 1111, 11111, 111111 are divided by 6 the remainders are 1, 5, 3, 1, 5, 3, three different numbers.
		

Crossrefs

Programs

  • Maple
    with(ListTools): a := proc (n) return add(10^i, i = 0 .. n-1) end proc: r := proc (n) return seq(`mod`(a(i), n), i = 1 .. n) end proc: seq(nops(MakeUnique([r(n)])), n = 1 .. 243);
    # Simpler:
    f:= n -> nops({seq(((10^i-1)/9) mod n,i=1..n)}):
    map(f, [$1..100]); # Robert Israel, Jun 25 2020
  • Mathematica
    Table[Length@ Union@ Array[Mod[(10^# - 1)/9, n] &, n], {n, 81}] (* Michael De Vlieger, Jun 28 2020 *)
  • PARI
    a(n) = #Set(vector(n, k, (10^k-1)/9) % n); \\ Michel Marcus, Jun 15 2020

A058987 a(n) = Catalan(n) - Motzkin(n-1).

Original entry on oeis.org

0, 1, 3, 10, 33, 111, 378, 1303, 4539, 15961, 56598, 202214, 727389, 2632605, 9581211, 35047098, 128791323, 475281921, 1760726808, 6545921136, 24415415001, 91340016081, 342658850427, 1288774386909, 4858753673655, 18358309669651
Offset: 1

Author

Sen-Peng Eu, Jan 17 2001

Keywords

Comments

Number of Dyck paths with a "small Capital N" (a rise then a fall then a rise) - this follows from the exercise on p. 238 of Stanley stating that Motzkin numbers equal to the ballot number without (1,-1,1). Since Ballot numbers are Catalan numbers, the result follows from the well-known bijection with Dyck paths.
a(n + 2) = p(n + 2) where p(x) is the unique degree-n polynomial such that p(k) = Catalan(k) for k = 1, 2, ..., n+1. - Michael Somos, Oct 07 2003

Examples

			x^2 + 3*x^3 + 10*x^4 + 33*x^5 + 111*x^6 + 378*x^7 + 1303*x^8 + 4539*x^9 + ...
a(4) = 10 since p(x) = x^2 - 2*x + 2 interpolates p(1) = 1, p(2) = 2, p(3) = 5, and p(4) = 10. - _Michael Somos_, Jan 05 2012
		

References

  • R. P. Stanley, Enumerative Combinatorics, Cambridge, Vol. 2, 1999; cf. p. 238.

Crossrefs

Programs

  • PARI
    {a(n) = if( n<2, 0, n--; subst( polinterpolate( vector(n, k, binomial( 2*k, k) / (k + 1))), x, n + 1))} /* Michael Somos, Jan 05 2012 */
    
  • PARI
    {a(n) = local(A); if( n<2, 0, n -= 2; A = x * O(x^n); polcoeff( 4 / ( (1 - 2*x + sqrt( 1 - 4*x + A )) * (1 - x + sqrt( 1 - 2*x - 3*x^2 + A)) - 4*x^2 ), n))} /* Michael Somos, Jan 05 2012 */
    
  • PARI
    { allocatemem(932245000); for (n = 1, 100, a=if(n<=1, 0, subst(polinterpolate(vector(n-1,k,binomial(2*k,k)/(k+1))),x,n)); write("b058987.txt", n, " ", a); ) } \\ Harry J. Smith, Jun 24 2009

Formula

G.f.: (sqrt( 1 - 2*x - 3*x^2 ) - sqrt( 1 - 4*x ) - x) / (2*x) = (4*x^2) / ( (1 - 2*x + sqrt( 1 - 4*x )) * (1 - x + sqrt( 1 - 2*x - 3*x^2 )) - 4*x^2). - Michael Somos, Jan 05 2012
a(n) = A000108(n) - A001006(n-1) if n>0.

A060802 To weigh from 1 to n, make the heaviest weight as small as possible, under the condition of using fewest pieces of different, single weights; a(n) = weight of the heaviest weight.

Original entry on oeis.org

1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7, 8, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 18, 18, 18, 19, 19, 20, 20, 21
Offset: 1

Author

Sen-Peng Eu, Apr 27 2001

Keywords

Comments

Starting at n = 2^x (x > 2) you get: 3 entries of 2^floor(log_2(x)-2)+2, then 2 entries of each subsequent integer until you reach the halfway point between 2^x and 2^(x+1), then 1 entry of each subsequent integer until you reach 2^(x+1)-1. Proved (see link). - David Consiglio, Jr., Jan 08 2015

Examples

			a(20)=7 because every number from 1 to 20 can be obtained from {1,2,4,6,7}.
		

Formula

After the 8th term:
If 2^x <= n <= (2^x)+2 then a(n) = 2 ^ floor(base2log(x)-2)+2 (see A052548)
If (2^x)+2 < n and n+1 < (2^x + 2^x+1)/2 then a(n) and a(n+1) = a(n-1)+1
If (2^x+2^x+1)/2 <= n then a(n) = a(n-1)+1. - David Consiglio, Jr., Jan 08 2015

Extensions

a(32)-a(1024) from David Consiglio, Jr., Jan 08 2015

A060422 Number of acute triangles made from vertices of a regular n-gon.

Original entry on oeis.org

0, 0, 0, 1, 0, 5, 2, 14, 8, 30, 20, 55, 40, 91, 70, 140, 112, 204, 168, 285, 240, 385, 330, 506, 440, 650, 572, 819, 728, 1015, 910, 1240, 1120, 1496, 1360, 1785, 1632, 2109, 1938, 2470, 2280
Offset: 0

Author

Sen-Peng Eu, Apr 05 2001

Keywords

Crossrefs

Union of A000330, A007290.

Programs

  • Mathematica
    LinearRecurrence[{1, 3, -3, -3, 3, 1, -1},{0, 0, 0, 1, 0, 5, 2}, 50] (* Vincenzo Librandi, Dec 25 2012 *)

Formula

a(n) = n*(n+1)*(n-1)/24 when n is odd, otherwise n*(n-2)*(n-4)/24.
G.f.: x^3*(2*x^2-x+1) / ((x-1)^4*(x+1)^3). - Colin Barker, Dec 24 2012
a(n) = n*(2*n^2-6*n+7-3*(2*n-3)*(-1)^n)/48. - Luce ETIENNE, Mar 19 2015

A060833 Separate the natural numbers into disjoint sets A, B with 1 in A, such that the sum of any 2 distinct elements of the same set never equals 2^k + 2. Sequence gives elements of set A.

Original entry on oeis.org

1, 4, 7, 8, 12, 13, 15, 16, 20, 23, 24, 25, 28, 29, 31, 32, 36, 39, 40, 44, 45, 47, 48, 49, 52, 55, 56, 57, 60, 61, 63, 64, 68, 71, 72, 76, 77, 79, 80, 84, 87, 88, 89, 92, 93, 95, 96, 97, 100, 103, 104, 108, 109, 111, 112, 113, 116, 119, 120, 121, 124, 125, 127, 128
Offset: 1

Author

Sen-Peng Eu, May 01 2001

Keywords

Comments

Can be constructed as follows: place of terms of (2^k+1,2^k+2,...,2^k) are the reflection from (2,3,4,...,2^k,1). [Comment not clear to me - N. J. A. Sloane]
If n == 0 mod 4, then n is in the sequence. If n == 2 mod 4, then n is not in the sequence. The number 2n - 1 is in the sequence if and only if n is in the sequence. For n > 1, n is in the sequence if and only if A038189(n-1) = 1. - N. Sato, Feb 12 2013
The set B contains all numbers 2^(k-1)+1 = (2^k+2)/2 (half of the "forbidden sums"), (2, 3, 5, 9, 17, 33, 65,...) = 1/2 * (4, 6, 10, 18, 34, 66, 130, 258,...). - M. F. Hasler, Feb 12 2013

Crossrefs

Essentially one more than A091067.
First differences: A106836.
A082410(a(n)) = 0.

Programs

  • Maple
    a:= proc(n) option remember; local k, t;
          if n=1 then 1
        else for k from 1+a(n-1) do t:= k-1;
               while irem(t, 2, 'r')=0 do t:=r od;
               if irem(t, 4)=3 then return k fi
             od
          fi
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 12 2013
  • Mathematica
    a[n_] := a[n] = Module[{k, t, q, r}, If[n == 1, 1, For[k = 1+a[n-1], True, k++, t = k-1; While[{q, r} = QuotientRemainder[t, 2]; r == 0, t = q]; If[Mod[t, 4] == 3, Return[k]]]]]; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jan 30 2017, after Alois P. Heinz *)
  • PARI
    a(n) = if(n=2*n-2, my(t=1); forstep(i=logint(n,2),0,-1, if(bittest(n,i)==t, n++;t=!t))); n+1; \\ Kevin Ryde, Mar 21 2021

Formula

a(1) = 1; and for n > 1: a(n) = A091067(n-1)+1. - Antti Karttunen, Feb 20 2015, based on N. Sato's Feb 12 2013 comment above.

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), May 10 2001

A071684 Number of plane trees with n edges and having an odd number of leaves.

Original entry on oeis.org

1, 1, 2, 7, 22, 66, 212, 715, 2438, 8398, 29372, 104006, 371516, 1337220, 4847208, 17678835, 64823110, 238819350, 883629164, 3282060210, 12233141908, 45741281820, 171529777432, 644952073662, 2430973304732, 9183676536076
Offset: 1

Author

Sen-peng Eu, Jun 23 2002

Keywords

Comments

Narayana transform (A001263) of [1, 0, 1, 0, 1, 0, 1, ...]. Example: a(4) = 7 = (1, 6, 6, 1) dot (1, 0, 1, 0) = (1 + 0 + 6 + 0). - Gary W. Adamson, Jan 04 2008

Examples

			a(3)=2 because among the 5 plane 3-trees there are 2 trees with odd number of leaves; a(4)=7 because among the 14 plane 4-trees there are 7 trees with odd number of leaves.
		

Crossrefs

a(n) + A071688 = A000108: Catalan numbers.

Programs

  • Maple
    G:=((1+4*x^2)^(1/2)-(1-4*x)^(1/2)-2*x)/4/x: Gser:=series(G,x=0,30): seq(coeff(Gser,x,n),n=1..26); # Emeric Deutsch, Feb 17 2007
  • Mathematica
    a[n_] := If[EvenQ[n], Binomial[2n, n]/(2n + 2), Binomial[2n, n]/(2n + 2) - (-1)^((n + 1)/2)Binomial[n - 1, (n - 1)/2]/(n + 1)]
    Table[(CatalanNumber[n] + 2^n Binomial[1/2, (n + 1)/2])/2, {n, 20}] (* Vladimir Reshetnikov, Oct 03 2016 *)

Formula

a(2*n) = (1/(4*n + 2))*binomial(4*n, 2*n);
a(2*n-1) = (1/(4*n))*binomial(4*n-2, 2*n-1) - (-1)^n*(1/(2*n))*binomial(2*n-2, n-1), with n>0.
G.f.: (1/4)*((1+4*x^2)^(1/2) - (1-4*x)^(1/2)-2*x)/x. - Vladeta Jovovic, Apr 19 2003
a(0)=0; a(n) = Sum_{k = 0..floor(n/2)} (1/n)*C(n,2*k+1)*C(n,2*k) for n>0. - Paul Barry, Jan 25 2007
a(n) = Sum_{k=1..n} (1/n)*C(n,k)*C(n,k-1)*(1-(-1)^k)/2. - Paul Barry, Dec 16 2008
Conjecture: n*(n+1)*(10*n-37)*a(n) + 2*n*(5*n^2-42*n+91)*a(n-1) + 4*(-40*n^3+270*n^2-560*n+357)*a(n-2) + 8*(n-3)*(5*n^2-42*n+91)*a(n-3) - 16*(n-4)*(25*n-51)*(2*n-7)*a(n-4) = 0. - R. J. Mathar, Jul 05 2018
a(n) = (A000108(n) + 2^n * binomial(1/2, (n+1)/2))/2. - Vladimir Reshetnikov, Oct 03 2016
32*n*(2*n+1)*a(n) - 48*(n+2)*(n+1)*a(n+1) + 8*(n^2-n-9)*a(n+2) - 4*(2*n^2+10*n+9)*a(n+3) - 2*(n+5)*(n+6)*a(n+4) + (n+5)*(n+6)*a(n+5) = 0. - Robert Israel, Jul 05 2018

Extensions

Edited by Robert G. Wilson v, Jun 25 2002

A060447 Cyclic token-passing numbers with pattern 121: players 1, 2, ..., n are seated around a table. Each has a penny. Player 1 passes a penny to player 2, who passes two pennies to player 3, who passes a penny to player 4. Player 4 passes a penny to player 5, who passes two pennies to player 6, who passes a penny to player 7 and so on, players passing 1,2,1,1,2,1,... pennies to the next player who still has some pennies. A player who runs out of pennies drops out of the game and leaves the table. Sequence gives number of players remaining when game reaches periodic state.

Original entry on oeis.org

1, 1, 1, 2, 2, 2, 2, 2, 2, 4, 4, 2, 5, 5, 4, 4, 4, 4, 4, 4, 8, 5, 8, 8, 5, 5, 8, 7, 7, 7, 11, 11, 11, 11, 11, 11, 11, 11, 11, 17, 17, 14, 7, 7, 11, 11, 11, 11, 19, 20, 20, 11, 11, 11, 14, 14, 22, 17, 17, 17, 16, 14, 14, 16, 20, 16, 10, 16, 17, 20, 20, 20, 23
Offset: 1

Author

Sen-Peng Eu, Apr 08 2001

Keywords

Examples

			a(10)=4 because 4 players (numbers 4, 6, 9, 10) remain.
		

References

  • Suggested by 58th William Lowell Putnam Mathematical Competition, 1997, Problem A-2.

Extensions

a(41) and a(51) corrected and more terms from Sean A. Irvine, Nov 20 2022