OFFSET
0,1
COMMENTS
The n-th r-gonal number 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
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; prevrGonal[r_, n_]:=nthrGonal[r, Floor[(Sqrt[((8r-16)n+(r-4)^2)]+r-4)/(2r-4)]]; (* previous r-gonal number greater than or equal to n *) Table[NestWhile[#+1&, 3, !rGonalQ[#, n-prevrGonal[#, 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