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.

A176079 Triangle T(n,k) read by rows: If k divides n then k-1, otherwise -1.

Original entry on oeis.org

0, 0, 1, 0, -1, 2, 0, 1, -1, 3, 0, -1, -1, -1, 4, 0, 1, 2, -1, -1, 5, 0, -1, -1, -1, -1, -1, 6, 0, 1, -1, 3, -1, -1, -1, 7, 0, -1, 2, -1, -1, -1, -1, -1, 8, 0, 1, -1, -1, 4, -1, -1, -1, -1, 9, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 0, 1, 2, 3, -1, 5, -1, -1, -1, -1, -1, 11
Offset: 1

Views

Author

Mats Granvik, Apr 08 2010

Keywords

Examples

			Table begins:
  0;
  0,  1;
  0, -1,  2;
  0,  1, -1,  3;
  0, -1, -1, -1,  4;
  0,  1,  2, -1, -1,  5;
  0, -1, -1, -1, -1, -1,  6;
  0,  1, -1,  3, -1, -1, -1,  7;
  0, -1,  2, -1, -1, -1, -1, -1,  8;
  0,  1, -1, -1,  4, -1, -1, -1, -1, 9;
		

Crossrefs

Cf. A001065 (row sums), A191904.

Programs

  • GAP
    T:= function(n,k)
        if (n mod k = 0) then return k-1;
        else return -1;
        fi; end;
    Flat(List([1..15], n-> List([1..n], k-> T(n,k) ))); # G. C. Greubel, Nov 27 2019
  • Magma
    [(n mod k) eq 0 select k-1 else -1: k in [1..n], n in [1..15]]; // G. C. Greubel, Nov 27 2019
    
  • Maple
    seq(seq( `if`(mod(n,k)=0, k-1, -1) , k=1..n), n=1..15); # G. C. Greubel, Nov 27 2019
  • Mathematica
    Table[If[Divisible[n,k],k-1,-1],{n,15},{k,n}]//Flatten (* Harvey P. Dale, May 20 2016 *)
  • PARI
    T(n,k)= if(Mod(n,k)==0, k-1, -1); \\ G. C. Greubel, Nov 27 2019
    
  • Sage
    def T(n, k):
        if (mod(n,k)==0): return k-1
        else: return -1
    [[T(n, k) for k in (1..n)] for n in (1..15)] # G. C. Greubel, Nov 27 2019
    

Formula

T(n,k) = -A191904(n,k) for n >= k.
Sum_{k=1..n} T(n,k) = A001065(n). - Jon E. Schoenfield, Nov 29 2019