<s>[INST] Find $A = x - y + z$ if $3x + 5y + 7z = 29$ and $x , y , z \in \mathbb{Z}^+$ I've found the answer by trial and error $(x = 4 , y=2,z=1) \Rightarrow$ $A = 3$. I tried to solve it using modular arithmetic but it didn't work .
$$3x + 5y + 7z = 29 $$
$$ 3x + 5y+7z \equiv 29  \mod 3$$
$$ 2y +z \equiv 2 \mod 3 $$
$$ y= -k , z=2k + 2$$
putting $ y= -k , z=2k + 2$ to original equation leads to $x = -3k + 5$ . Then $A = -3k+5 +k +2k+2 = 7$ . What's wrong about my answer? 
 [/INST] Starting from your 3.rd line. For some integer $t$ we have $$2y+z-2 = 3t\implies z = 2+3t-2y$$
So $$3x+5y+7(2+3t-2y) = 29\implies 3x = 15-21t+9y$$
so $$x = 5-7t+3y$$
thus $$A = 5-7t+3y -y+2+3t-2y=-4t+7$$
Since $2y+z\geq 3\implies 3t+2\geq 3\implies t\geq 1$
Since $z\leq 4$ and $y\leq 5$ we get $3t+2\leq 14$ so $t\leq 4$. 
</s>