How to check if a number is present in the series $1, 7, 25, 63, 129, 231...$?
The nth term of the series is $(2 n + 1) (2n^2 + 2 n + 3) / 3$.
if $N = 7$, then it is present in the series.
How to check if a number is present in the series $1, 7, 25, 63, 129, 231...$?
The nth term of the series is $(2 n + 1) (2n^2 + 2 n + 3) / 3$.
if $N = 7$, then it is present in the series.
Suppose we seek an $n$ solving $O_n=N$, with $n$th centered octahedral number$$O_n:=\frac13(2n+1)(2n^2+2n+3)\in(\tfrac16(2n)^3,\,\tfrac16(2n+1)^3).$$Since $(2n)^3\le6N\le(2n+1)^3$, there's at most one candidate $n$ to check.
This is the sequence A001845 giving the centered octahedral numbers (crystal ball sequence for cubic lattice). For smaller numbers you can simply check the given list there.
Of course, with a formula at hand, you can simply solve the equation $$ (2n+1)(2n^2+2n+3)/3=k $$ for $n$ and see if it has an integral solution. For example, take $k=20$. The formula shows that we need $n<2$. But for $n=0,1$ it is false. So first, estimate $n$, and then check for those $n$.
$$6N=8n^3+12n^2+16n+6\\=(2n+1)^3+5(2n+1)$$ Let $$M =round\left(\sqrt[3]{6N-5\sqrt[3]{6N}}\right)$$ If $6N-5M=M^3$, and $M$ is odd, then I think $N$ is in the sequence.