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.

A171712 Triangle T(n,k) read by rows. Coloring of sectors in a circle.

Original entry on oeis.org

1, 1, 2, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2
Offset: 1

Views

Author

Mats Granvik, Dec 16 2009

Keywords

Comments

One row equals a coloring of n sectors in a circle and each number in the k-th column represents a color in the k-th sector of the circle. No pair of adjacent sectors can have the same color. The smallest numbers are chosen as colors and they are ordered from smallest to largest.

Examples

			Table begins:
  1;
  1, 2;
  1, 2, 3;
  1, 2, 1, 2;
  1, 2, 1, 2, 3;
  1, 2, 1, 2, 1, 2;
  1, 2, 1, 2, 1, 2, 3;
  1, 2, 1, 2, 1, 2, 1, 2;
		

Crossrefs

Cf. A158478.

Programs

  • GAP
    T:= function(n,k)
        if k=1 then return 1;
        elif k=n then return (5-(-1)^n)/2;
        else return (3+(-1)^k)/2; fi; end;
    Flat(List([1..15], n-> List([1..n], k-> T(n,k) ))); # G. C. Greubel, Nov 29 2019
  • Magma
    function T(n,k)
      if k eq 1 then return 1;
      elif k eq n then return (5-(-1)^n)/2;
      else return (3+(-1)^k)/2;  end if; return T; end function;
    [T(n,k): k in [1..n], n in [1..15]]; // G. C. Greubel, Nov 29 2019
    
  • Maple
    seq(seq( `if`(k=1, 1, `if`(k=n, (5-(-1)^n)/2, (3+(-1)^k)/2 )), k=1..n), n=1..15); # G. C. Greubel, Nov 29 2019
  • Mathematica
    T[n_, k_]:= If[k==1, 1, If[k==n, (5-(-1)^n)/2, (3+(-1)^k)/2]]; Table[T[n, k], {n, 15}, {k, n}]//Flatten (* G. C. Greubel, Nov 29 2019 *)
  • PARI
    T(n,k) = if(k==1, 1, if(k==n, (5-(-1)^n)/2, (3+(-1)^k)/2 )); \\ G. C. Greubel, Nov 29 2019
    
  • Sage
    def T(n, k):
        if (k==1): return 1
        elif (k==n): return (5-(-1)^n)/2
        else: return (3+(-1)^k)/2
    [[T(n, k) for k in (1..n)] for n in (1..15)] # G. C. Greubel, Nov 29 2019
    

Formula

T(n, k) = (3 + (-1)^k)/2 with T(n, 1) = 1 and T(n, n) = (5 - (-1)^n)/2 for n >= 2. - G. C. Greubel, Nov 29 2019