Function identifying consecutive integers I am looking for a function $f(a,b,c)$ defined on triplets of integers so that $f(a,b,c)=0$ if and only if $a$,$b$,$c$ form a set of 3 consecutive integers.
Is there such function in closed form?
 A: It's possible to make a polynomial with this property. If $p$ is a polynomial with real coefficients, let $Z(p)$ denote the set of real zeros of $p$. Then, for polynomials $p$ and $q$,
$$Z(p^2+q^2)=Z(p)\cap Z(q),\ \ Z(pq)=Z(p)\cup Z(q).$$
Using this, we can write the polynomial $g(a,b,c)=(b-a-1)^2+(c-b-1)^2$, which is $0$ if and only if $b=a+1$ and $c=b+1$ (i.e. if $a,b,c$ are three consecutive integers in that order), and then
$$f(a,b,c)=g(a,b,c)g(a,c,b)g(b,a,c)g(b,c,a)g(c,a,b)g(c,b,a)$$
has the desired property.
A: One particularly simple polynomial is
$$f(a,b,c)=a^2+b^2+c^2-ab-bc-ca-3,$$
whose only integer zeros are when $\{a,b,c\}=\{n-1,n,n+1\}$ for some $n$, but which has other real zeros. To show that $f(a,b,c)=0$ when $\{a,b,c\}=\{n-1,n,n+1\}$ one simply needs to plug in $(a,b,c)=(n-1,n,n+1)$ and note that the function is symmetric. To show that these are the only zeros, note that
$$f(a,b,c)=\frac{(a-b)^2+(b-c)^2+(c-a)^2-6}2;$$
the only way to write $6$ as the sum of three integer squares is $2^2+1^2+1^2$, and so if $f(a,b,c)=0$ then the numbers $|a-b|$, $|b-c|$, and $|c-a|$ contain two $1$s and one $2$. This means that one of the numbers differs from each of the others by $1$; the two others cannot be equal, and so the three numbers must be consecutive.
