solutions of the equation $x^3-y^3=z!-18$ What are the solutions of the equation $x^3-y^3=z!-18$? Here $x,y,z$ are non-negative integers. I have tried brute force but is there a better method?
 A: You can even solve this if $x,y,z\in\mathbb Z$ can also be negative. Note that $z!$ is never defined when $z<0$.
By Fermat's Little Theorem for all $a\in\mathbb Z$ we have $a^6\equiv 0,1\pmod{7}$ and so $a^3\equiv -1,0,1\pmod{7}$.
If $z\ge 7$, then $$x^3-y^3\equiv 0-18\equiv 3\pmod{7},$$ impossible, because $$x^3-y^3\equiv -2,-1,0,1,2\pmod{7}$$
Therefore $0\le z\le 6$. Then you can analyse each $7$ (or $6$, since $0!=1!$) case by using factorization:
$$x^3-y^3=(x-y)\left(x^2+xy+y^2\right)=t$$
for an integer $t$. One thing that will help is that $$x^2+xy+y^2=\frac{1}{4}(2x+y)^2+\frac{3}{4}y^2\ge 0$$
You'll solve systems of equations. E.g., if $z=4$, then $$(x-y)\left(x^2+xy+y^2\right)=6$$
and the cases are $x-y=6$, $x^2+xy+y^2=1$
or $x-y=3$, $x^2+xy+y^2=2$
or $x-y=2$, $x^2+xy+y^2=3$
or $x-y=1$, $x^2+xy+y^2=6$.
Which is $4$ systems of equations. E.g., in the first one, $y=x-6$ and so $x^2+x(x-6)+(x-6)^2=1$ is a simple quadratic equation in terms of $x$.
Another method here is noticing increase of differences between consecutive cubes. $2^3-1^3>6$ and $1^3-(-1)^3<6$ and $(-1)^3-(-2)^3>6$.
From the other answer you can tell that $z\not\in\{3,4,5\}$ by noticing that if $z\ge 3$, then $3\mid x^3-y^3$, but by Fermat's Little Theorem then $3\mid x-y$, and also $x^2+xy+y^2\equiv 3x^2\equiv 0\pmod{3}$, so $9\mid z!$, so $z\ge 6$.
A: We can write equation in this form: $(x-y)^3+3xy(x-y)=z!-18$.
For $z\leq 2$:
If $x$ and $y$ give different residues modulo 3, then $z\in \{0,1,2\}$ (otherwise LS would be 1 or 2 modulo 3 and RS would be divisible by 3). 
It can be easily check that only solution is $z=2$, $x=-2$, $y=2$.
For $z\geq 3$:
From previous part, we have $3|(x-y)$. Therefore, $9|z!$, so it must be $z\geq 6$. 
Also, since $9|x^3-y^3$, we have $3|x-y$ and $27|x^3-y^3$. 
For $z\geq 9$, we have $18=y^3-x^3+z!$ which is not possible, since LS is not divisible by 27 and RS is divisible by 27. Therefore, only left solutions are from set $z\in\{6,7,8\}$.
For $z=6$ solutions are $x=-3$, $y=-9$ and $x=9$, $y=3$. Checking other solutions for $z\in\{6,7,8\}$ is left to reader.
