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: Adam Vellender

Adam Vellender's wiki page.

Adam Vellender has authored 2 sequences.

A330197 Number of scalene triangles whose vertices are the vertices of a regular n-gon.

Original entry on oeis.org

0, 0, 0, 12, 14, 32, 54, 80, 110, 168, 208, 280, 360, 448, 544, 684, 798, 960, 1134, 1320, 1518, 1776, 2000, 2288, 2592, 2912, 3248, 3660, 4030, 4480, 4950, 5440, 5950, 6552, 7104, 7752, 8424, 9120, 9840, 10668, 11438, 12320, 13230, 14168, 15134, 16224, 17248
Offset: 3

Author

Adam Vellender, Dec 05 2019

Keywords

Comments

The number of scalene triangles equals (number of triangles, i.e., binomial(n,3)) - (number of isosceles triangles).
The general formula is readily proved true by counting arguments.

Examples

			Trivial cases:
a(3)=0 since the only triangle formed by joining vertices is equilateral.
a(4)=a(5)=0 since all such triangles are isosceles.
For higher n, since a triangle is formed by choosing 3 vertices and joining them, there are C(n,3) such triangles. To obtain the number of scalene triangles, subtract the number of isosceles triangles (A320577).
		

Crossrefs

Cf. A320577 (isosceles triangles).

Programs

  • Mathematica
    a[n_] := If[Mod[n,6]==1 || Mod[n,6]==5, Binomial[n,3]-Binomial[n,2], If[Mod[n,6]==2 || Mod[n,6]==4, Binomial[n,3]-n*(n-2)/2,
    If[Mod[n, 6]==3, Binomial[n,3]-n*(3*n-7)/6, Binomial[n,3]-n*(3*n - 10)/6]]]; Array[a, 20, 3]
    LinearRecurrence[{0,2,2,-1,-4,-1,2,2,0,-1},{0,0,0,12,14,32,54,80,110,168},50] (* Harvey P. Dale, Aug 20 2021 *)
  • PARI
    concat([0,0,0], Vec(2*x^6*(2 + x)*(3 + 2*x + x^2) / ((1 - x)^4*(1 + x)^2*(1 + x + x^2)^2) + O(x^60))) \\ Colin Barker, Jan 08 2020
  • Python
    from sympy import binomial
    def a(n):
        assert (n>=3),"Sequence a(n) defined for n>=3"
        m = n % 6
        Cn3 = binomial(n, 3)
        if m in [1,5]:   return Cn3 - (n*(n-1))//2
        elif m in [2,4]: return Cn3 - (n*(n-2))//2
        elif m==3:       return Cn3 - (n*(3*n-7))//6
        else:            return Cn3 - (n*(3*n-10))//6
    print([a(k) for k in range(3,51)])
    

Formula

a(n) = binomial(n,3) - A320577(n).
a(n) = C(n,3)-n*(n-1)/2 if n mod 6 = 1 or 5; C(n,3)-n*(n-2)/2 if n mod 6 = 2 or 4; C(n,3)-n*(3*n-7)/6 if n mod 6 = 3; C(n,3)-n*(3*n-10)/6 otherwise [C(n,k) denoting binomial coefficients].
G.f.: 2*x^6*(2+x)*(3+x*(2+x))/((x-1)^4*(x+1)^2*(1+x+x^2)^2).
a(n) = 2*a(n-2) + 2*a(n-3) - a(n-4) - 4*a(n-5) - a(n-6) + 2*a(n-7) + 2*a(n-8) - a(n-10) for n>12. - Colin Barker, Jan 08 2020

A309000 Number of strings of length n from a 3-symbol alphabet (A,B,C, say) containing at least one "A" and at least two "B"s.

Original entry on oeis.org

3, 22, 105, 416, 1491, 5034, 16365, 51892, 161799, 498686, 1524705, 4635528, 14037627, 42391378, 127763925, 384536924, 1156232175, 3474201510, 10434138825, 31326533680, 94029932643, 282194655482, 846802070205, 2540859195396, 7623517110231, 22872497487694
Offset: 3

Author

Adam Vellender, Jul 04 2019

Keywords

Comments

This sequence can be thought of as the number of ways of rolling n 3-sided dice (with sides "A", "B", and "C") and obtaining at least one A and at least two B's.
The general formula is readily proved true by counting arguments.

Examples

			Suppose three-sided dice each have sides labeled A,B,C.
If there are three dice, then ABB, BAB, and BBA are the three strings resulting from rolling the dice satisfying the property of at least one A and at least two B's, hence a(3)=3 [Note a(0)=a(1)=a(2)=0].
If there are four such dice, there are 22 such permutations, hence a(4)=22: AABB, ABAB, ABBA, ABBB, ABBC, ABCB, ACBB, BAAB, BABA, BABB, BABC, BACB, BBAA, BBAB, BBAC, BBBA, BBCA, BCAB, BCBA, CABB, CBAB, CBBA.
		

Programs

  • Magma
    [3^n-2^(n+1)-n*2^(n-1)+n+1: n in [3..40]]; // Vincenzo Librandi, Jul 05 2019
  • Mathematica
    Array[3^# - 2^(# + 1) - # 2^(# - 1) + # + 1 &, 27, 3] (* or *)
    CoefficientList[Series[(-3 + 5 x)/((-1 + 3 x) (1 - 3 x + 2 x^2)^2), {x, 0, 26}], x] (* Michael De Vlieger, Jul 04 2019 *)
  • Python
    [3**n-2**(n+1)-n*2**(n-1)+n+1 for n in range(3,20)]
    

Formula

a(n) = 3^n - 2^(n+1) - n*2^(n-1) + n + 1.
G.f.: x^3*(-3 + 5*x)/((-1 + 3*x)*(1 - 3*x + 2*x^2)^2). - Michael De Vlieger, Jul 04 2019.
a(n) = 9*a(n-1) - 31*a(n-2) + 51*a(n-3) - 40*a(n-4) + 12*a(n-5) for n > 7. - Stefano Spezia, Jul 05 2019