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.

A227321 a(n) is the least r>=3 such that the difference between the nearest r-gonal number >= n and n is an r-gonal number.

Original entry on oeis.org

3, 3, 3, 3, 4, 3, 3, 3, 4, 3, 3, 5, 3, 8, 3, 3, 4, 5, 3, 11, 3, 3, 3, 5, 4, 3, 10, 3, 3, 11, 3, 17, 4, 3, 5, 3, 3, 7, 14, 3, 4, 15, 3, 23, 3, 3, 5, 11, 4, 3, 5, 5, 3, 19, 3, 3, 3, 8, 5, 21, 3, 32, 14, 3, 4, 3, 3, 15, 3, 5, 5, 25, 3, 38, 7, 3, 6, 3, 3, 13, 4, 3
Offset: 0

Views

Author

Vladimir Shevelev, Jul 30 2013

Keywords

Comments

The n-th r-gonal numbers is n((n-1)r-2(n-2))/2, such that 3-gonal numbers are triangular numbers, 4-gonal numbers are squares, etc.

Crossrefs

Cf. A000217 (r=3), A000290 (r=4), A000326 (r=5), A000384 (r=6), A000566 (r=7), A000567 (r=8), A001106-7 (r=9,10), A051682 (r=11), A051624 (r=12), A051865-A051876 (r=13-24).

Programs

  • Mathematica
    rGonalQ[r_,0]:=True; rGonalQ[r_,n_]:=IntegerQ[(Sqrt[((8r-16)n+(r-4)^2)]+r-4)/(2r-4)]; nthrGonal[r_,n_]:=(n (r-2)(n-1))/2+n; nextrGonal[r_,n_]:=nthrGonal[r,Ceiling[(Sqrt[((8r-16)n+(r-4)^2)]+r-4)/(2r-4)]]; (* next r-gonal number greater than or equal to n *) Table[NestWhile[#+1&,3,!rGonalQ[#,nextrGonal[#,n]-n]&],{n,0,99}] (* Peter J. C. Moses, Aug 03 2013 *)

Formula

If n is prime, then n == 1 or 2 mod (a(n)-2). If n >= 13 is the greater of a pair of twin primes (A006512), then a(n) = (n+3)/2. - Vladimir Shevelev, Aug 07 2013

Extensions

More terms from Peter J. C. Moses, Jul 30 2013