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

A128223 a(n) = if n mod 2 = 0 then n*(n+1)/2 otherwise (n+1)^2/2-1.

Original entry on oeis.org

0, 1, 3, 7, 10, 17, 21, 31, 36, 49, 55, 71, 78, 97, 105, 127, 136, 161, 171, 199, 210, 241, 253, 287, 300, 337, 351, 391, 406, 449, 465, 511, 528, 577, 595, 647, 666, 721, 741, 799, 820, 881, 903, 967, 990, 1057, 1081, 1151, 1176, 1249, 1275, 1351, 1378, 1457, 1485
Offset: 0

Views

Author

Gary W. Adamson, Feb 19 2007

Keywords

Comments

a(n-1) is the length of the shortest path along the edges of the complete graph with n vertices. - Martin Fuller, Dec 06 2007
From Peter Kagey, Jan 25 2015: (Start)
For an irreflexive, non-transitive, symmetric relation, a(n) is the length of a relation chain required to demonstrate that a != b for all distinct elements a and b in S, where S contains n+1 elements.
For example, for the set {1,2,3} the chain requires a(2) = 3 relations (e.g., 1 != 2 != 3 != 1). For the set {1,2,3,4}, the chain requires a(3) = 7 relations (e.g., 1 != 2 != 3 != 4 != 1 != 3 != 2 != 4 -- noting the redundancy of 2!=3 and 3!=2). (End)
Given a set of n lots of n distinct items, it is possible to sort the items from fully collated (ABCABCABC) to fully sorted (AAABBBCCC), or vice versa, using a sorting algorithm whereby at each step a portion of the overall string is selected and its contents reversed. The minimum number of steps such an algorithm will take is a(n-1). For example, when n=3, a(n-1)=3: ABCABCABC -> ABBACBACC -> ABBAABCCC -> AAABBBCCC. - Elliott Line, Aug 02 2019

Examples

			a(5) = 17 = (5 + 1 + 5 + 1 + 5), row 5 of A128222.
		

Crossrefs

Row sums of A128222.
Cf. A024206, row sums of A128221 = A128174 * A127701.

Programs

  • Haskell
    a128223 n = if even n then n*(n + 1) `div` 2 else (n+1)^2 `div` 2 - 1 -- Peter Kagey, Jul 14 2015
    
  • Magma
    [(-1+(-1)^n-(-3+(-1)^n)*n+2*n^2)/4: n in [0..60]]; // Vincenzo Librandi, Mar 18 2015
    
  • Maple
    f:=n-> if n mod 2 = 0 then n*(n+1)/2 else (n+1)^2/2-1; fi;
  • Mathematica
    f[n_] := If[EvenQ@ n, n (n + 1)/2, (n + 1)^2/2 - 1]; Array[f, 54] (* Michael De Vlieger, Mar 17 2015 *)
    Table[(- 1 + (-1)^n - (- 3 + (-1)^n) n + 2 n^2) / 4, {n, 0, 60}] (* Vincenzo Librandi, Mar 18 2015 *)
    CoefficientList[ Series[(-x - 2x^2 - 2x^3 + x^4)/((-1 + x)^3 (1 + x)^2), {x, 0, 54}], x] (* Robert G. Wilson v, Nov 16 2016 *)
    LinearRecurrence[{1,2,-2,-1,1},{0,1,3,7,10},60] (* Harvey P. Dale, Mar 17 2020 *)
  • PARI
    main(size)={my(n,m,v=vector(size),i);for(i=0,size-1,v[i+1]=if(i%2==0,i*(i+1)/2,(i+1)^2/2-1));return(v);} /* Anders Hellström, Jul 14 2015 */

Formula

a(n) = (-1+(-1)^n-(-3+(-1)^n)*n+2*n^2)/4. a(n) = a(n-1)+2*a(n-2)-2*a(n-3)-a(n-4)+a(n-5). G.f.: x*(x^3-2*x^2-2*x-1) / ((x-1)^3*(x+1)^2). - Colin Barker, Oct 16 2013
a(n) = A053439(n) - 1. - Peter Kagey, Nov 16 2016

Extensions

Edited by N. J. A. Sloane, Dec 06 2007

A362652 Expansion of g.f. x*(-2 - 2*x + x^2 - x^3)/((1 + x)^2 *(-1 + x)^3).

Original entry on oeis.org

2, 4, 7, 12, 16, 24, 29, 40, 46, 60, 67, 84, 92, 112, 121, 144, 154, 180, 191, 220, 232, 264, 277, 312, 326, 364, 379, 420, 436, 480, 497, 544, 562, 612, 631, 684, 704, 760, 781, 840, 862, 924, 947, 1012, 1036, 1104, 1129, 1200, 1226, 1300, 1327
Offset: 1

Views

Author

Jonathon Priestley, Apr 28 2023

Keywords

Comments

a(n) gives the number of vertices encountered along the shortest walk that encounters every edge at least once on the graph with n vertices where the graph is both complete and every node also has an edge to itself.
a(n) can be thought of as the length of a list made up using n distinct elements where every element is next to every other element (including a copy of itself) at least once. Such a list could be used forwards and backward when kerning a font as a way to minimize the number of characters typed in total.

Examples

			G.f.: 2*x + 4*x^2 + 7*x^3 + 12*x^4 + 16*x^5 + 24*x^6 + 29*x^7 + 40*x^8 + 46*x^9 + ...
		

Crossrefs

Cf. A053439.

Programs

  • Mathematica
    CoefficientList[Series[x(-2-2x+x^2-x^3)/((1+x)^2(-1+x)^3), {x, 0, 50}], x]
    (* or *)
    LinearRecurrence[{1, 2, -2, -1, 1}, {2, 4, 7, 12, 16}, 50]
  • Python
    def a(n: int): return n + (n & 1) + n * ( n >> 1 )

Formula

a(n) = n + (n mod 2) + (n * (n - (n mod 2)))/2.
a(2*n) = 2*n + 2*n^2;
a(2*n - 1) = 1 - n + 2*n^2.
E.g.f.: (2 + x)*(exp(x)*x + sinh(x))/2. - Stefano Spezia, May 07 2023

A278299 a(n) is the tile count of the smallest polyomino with an n-coloring such that every color is adjacent to every other distinct color at least once.

Original entry on oeis.org

2, 4, 6, 9, 12, 15, 19, 24, 30, 34
Offset: 2

Views

Author

Alec Jones and Peter Kagey, Nov 17 2016

Keywords

Comments

Only edge-to-edge adjacencies are considered.
The sequence is bounded above by A053439(n-1).
a(n) is bounded below by n * ceiling((n - 1)/4). This bound is achieved for n=2, n=6, and n=10.

Examples

			Example: for n = 4, the following diagram gives a minimal polyomino of a(4) = 6 tiles:
      +---+---+
      | 1 | 4 |
  +---+---+---+
  | 4 | 3 | 2 |
  +---+---+---+
          | 1 |
          +---+
Example: for n = 10, the following diagram gives a minimal polyomino of a(10) = 30 tiles. Note that redundant adjacencies, e.g., between 2 and 7, can exist in minimal diagrams.
              +---+---+
              | 8 | 6 |
          +---+---+---+---+---+
          | 3 | 2 | 5 | 9 | 4 |
  +---+---+---+---+---+---+---+---+
  | 2 | 7 | 5 | 1 | 4 | 2 | 10| 9 |
  +---+---+---+---+---+---+---+---+
  | 6 | 9 | 8 | 3 | 6 | 7 | 8 | 1 |
  +---+---+---+---+---+---+---+---+
  | 10| 3 | 4 | 7 | 1 | 10| 5 |
  +---+---+---+---+---+---+---+
From _Ryan Lee_, May 14 2019: (Start)
Example for n = 11:
  +---+---+---+---+---+
  | 9 | 11| 2 | 5 | 8 |
  +---+---+---+---+---+---+
  | 1 | 5 | 10| 9 | 2 | 1 |
  +---+---+---+---+---+---+
  | 4 | 6 | 11| 8 | 7 | 3 |
  +---+---+---+---+---+---+
  | 3 | 9 | 7 | 10| 6 | 2 |
  +---+---+---+---+---+---+
  | 11| 4 | 5 | 3 | 8 | 4 |
  +---+---+---+---+---+---+
  | 1 | 10|   | 6 | 1 | 7 |
  +---+---+   +---+---+---+
(End)
		

Crossrefs

Cf. A053439.

Extensions

a(11) from Ryan Lee, May 14 2019
Showing 1-3 of 3 results.