OFFSET
3,1
COMMENTS
LINKS
Michel Marcus, Table of n, a(n) for n = 3..10000
Eric W. Weisstein, Polygonal Number. MathWorld.
EXAMPLE
a(12) = 5 since 12 is a pentagonal number, but not a square or triangular number. - Michael B. Porter, Jul 16 2016
MATHEMATICA
a[n_] := (m = 3; While[Reduce[k >= 1 && n == k (k (m - 2) - m + 4)/2, k, Integers] == False, m++]; m); Table[a[n], {n, 3, 100}] (* Jean-François Alcover, Sep 04 2016 *)
PROG
(PARI) a(n) = {k=3; while (! ispolygonal(n, k), k++); k; } \\ Michel Marcus, Mar 25 2015
(Python)
from __future__ import division
from gmpy2 import isqrt
def A176774(n):
k = (isqrt(8*n+1)-1)//2
while k >= 2:
a, b = divmod(2*(k*(k-2)+n), k*(k-1))
if not b:
return a
k -= 1 # Chai Wah Wu, Jul 28 2016
CROSSREFS
KEYWORD
nonn
AUTHOR
Max Alekseyev, Apr 25 2010
STATUS
approved