OFFSET
0,1
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.
LINKS
Peter J. C. Moses, Table of n, a(n) for n = 0..1999
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
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 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Vladimir Shevelev, Jul 30 2013
EXTENSIONS
More terms from Peter J. C. Moses, Jul 30 2013
STATUS
approved