Artificial intelligent assistant

Determine if a specific number is -gonal I am currently working with -gonal numbers (pentagonal, hexagonal, pentagonal) and I have run into a bit of an issue. Currently, if I want to know the nth -gonal number I can work that out. For example, If I wanted to know the nth heptagonal number I would be able to find it by: $ \sum (5i - 4)$ I am unsure on how to extrapolate on what I know to find out if a specific number is a -gonal number. For example, if I wanted to know if 4567 is a heptagonal number, I am not sure where to solve for this other than just find all the -gonal numbers until I surpass the one i'm looking for, which I imagine to be way too time consuming. My work: I know a triangle is $\sum (i)$ and I know that we can solve that by the formula $(n(n+1))/2$ and I tried substituting in $(5i - 4)$ for the sum formula, but that didn't seem to work.

For constants $a,b$ you have

$$\sum_{i=1}^n ai+b = a \sum_{i=1}^n i + b \sum_{i=1}^n 1 = \frac{a n(n+1)}{2} + bn.$$

You can set this equal to your given number and solve for $n$; if you get an integer then your given number was whatever-gonal.

I'm not sure if this _fully_ answers your question, since I'm not that closely familiar with the -gonal numbers.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 1de52e505654ed2a734a6f733557f0c7