login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
3

%I #28 Aug 13 2013 06:13:57

%S 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,

%T 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,

%U 14,3,4,3,3,15,3,5,5,25,3,38,7,3,6,3,3,13,4,3

%N 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.

%C 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.

%H Peter J. C. Moses, <a href="/A227321/b227321.txt">Table of n, a(n) for n = 0..1999</a>

%F 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

%t 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 *)

%Y 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).

%K nonn

%O 0,1

%A _Vladimir Shevelev_, Jul 30 2013

%E More terms from _Peter J. C. Moses_, Jul 30 2013