Valid term from quadratic sequence?

JavaScript (ES7), 70 bytes

Returns a Boolean value.


Try it online!


For the sake of clarity, we define \$d = T_n-c\$. (The same variable \$t\$ is re-used to store this result in the JS code.)

Case \$a\neq0\$

The equation really is quadratic:

$$T_n=an^2+bn+c\\ an^2+bn-d=0$$

With \$a'=2a\$, the discriminant is:


and the roots are:

$$n_0=\frac{-b-\sqrt{\Delta}}{a'}\\ n_1=\frac{-b+\sqrt{\Delta}}{a'}$$

The equation admits an integer root if \$\sqrt{\Delta}\$ is an integer and either:

$$\begin{align}&-b-\sqrt{\Delta}\equiv 0\pmod{a'}\\ \text{ or }&-b+\sqrt{\Delta}\equiv 0\pmod{a'}\end{align}$$

Case \$a=0, b\neq0\$

The equation is linear:

$$T_n=bn+c\\ bn=d\\ n=\frac{d}{b}$$

It admits an integer root if \$d\equiv0\pmod b\$.

Case \$a=0, b=0\$

The equation is not depending on \$n\$ anymore:

$$T_n=c\\ d=0$$

Jelly,  11  10 bytes


A monadic Link which accepts a list of lists* [[c, b, a], [T_n]] and yields 0 if T_n is a valid solution or 1 if not.

* admittedly taking a little liberty with "You may take input of these four numbers in any way".

Try it online! Or see a test-suite.


_/Ær1Ẹ?%1Ạ - Link: list of lists of integers, [[c, b, a], [T_n]]
 /         - reduce by:
_          -   subtraction                    [c-T_n, b, a]
      ?    - if...
     Ẹ     - ...condition: any?
  Ær       - ...then: roots of polynomial     i.e. roots of a²x+bx+(c-T_n)=0
    1      - ...else: literal 1
       %1  - modulo 1 (vectorises)            i.e. for each: keep any fractional part
           -                                       note: (a+bi)%1 yields nan which is truthy
         Ạ - all?                             i.e. all had fractional parts?
           -                                       note: all([]) yields 1

If we could yield non-distinct results then _/Ær1Ẹ?ḞƑƇ would also work for 10 (it yields 1 when all values are solutions, otherwise a list of the distinct solutions and hence always an empty list when no solutions - this would also meet the standard Truthy vs Falsey definition)