If this a quadratic sequence f(n)=an2+bn+c where a, b, c are constant coefficients.
f(1)=1, f(2)=7, f(3)=17, f(4)=31. We only need three equations when the sequence is quadratic, so we'll just use f(1)-f(3). If the sequence is quadratic then f(4)=31 should automatically follow. If it doesn't, the sequence is not quadratic.
a+b+c=1=f(1),
4a+2b+c=7=f(2),
9a+3b+c=17=f(3),
f(2)-f(1)=3a+b=6,
f(3)-f(1)=8a+2b=16,
2(f(2)-f(1))=6a+2b=12,
f(3)-f(1)-(2(f(2)-f(1)))=2a=4, a=2⇒b=6-3a=0⇒2+0+c=1, c=-1.
f(n)=2n2-1⇒f(1)=2-1=1; f(2)=2×4-1=7; f(3)=2×9-1=17. So far so good.
f(4)=2×16-1=31, which is correct.
f(n)=799, so 2n2-1=799, 2n2=800, n2=400, n=20.