<s>[INST] What is a quick way (without calculator) to determine that $(2^9 + 1)^2 + 2^9 + 2$ is not prime? I came across the following expression $(2^9 + 1)^2 + 2^9 + 2$, which is divisible by 7 and thus not prime. Without this information and a calculator, how could I easily determine that this number is not prime?
Here is a way I thought of how to determine whether 7 is a factor, but I don't really like this approach because if I got that expression above, I'm not going to know to check for 7 right away, and this approach also requires me to know modulo arithmetic, which I'm not too familiar with.
$$
(2^9 + 1)^2 = (513*513) \\
(513*513) \% 7 = (513 \% 7 * 513 \% 7) \% 7 = (2 * 2) \% 7 = 4 \\
(2^9 + 2) \% 7 = 3 \\
(3 + 4) \% 7 = 0
$$
 [/INST] $$A=(2^9 + 1)^2 + 2^9 + 2$$

$$\begin{align}\color{red}{A-7}=\left(2^9-1+2\right)^2+2^9+2-7=(a+2)^2+2^9-5=a^2+4a+2^9-1=a^2+4a+a=\color{red}{a^2+5a}\end{align}$$
,where $a=2^9-1=\left(2^3\right)^3-1=\left(2^3-1\right)\left(2^6+2^3+1\right)=7×\left(2^6+2^3+1\right).$

So, $(A-7) \mod 7=0 \Longrightarrow A\mod 7=0.$
The shorter way can be done as follows: (based on the result we get)
$$\begin{align} (2^9 + 1)^2 + 2^9 + 2= 49×\left(2^6+2^3+1\right)^2+35×\left(2^6+2^3+1\right)+7.\end{align}$$
</s>