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
$$
 A: The factors are $7\cdot 139\cdot 271$; it's not getting much better by avoiding $7$. One thing that does help is that $2^3\equiv 1\pmod 7$, so the expression looks like $(1+1)^2+1+2\pmod 7$, which is immediately zero.
A: Here's a way to know to check for $7$.
Your number is clearly a polynomial in $2^9$, so the first thing I would think of is to see if this polynomial factors. Letting $n=2^9$, the polynomial is $n^2+3n+3$, so no luck there.
You may notice that this number is $\frac{(n+1)^3-1}{n}$, so we want to find a factor of $(2^9+1)^3-1$ that is odd. Because the only (easy) way to factor a cube minus one is the factorization $x^3-1=(x-1)(x^2+x+1)$, we might want to try some prime factors. We can tell that $3$ doesn't divide our number since $3\nmid n$. Also, you can check (or you might know) that $x^3\equiv 1\bmod p$ if and only if $x\equiv 1\bmod p$ for all primes $p$ that are $2\bmod 3$. This means we only want to worry about primes that are $1\bmod 3$, the smallest of which is $7$.
A: this expression is equal to
$2^{18}+2^{10}+2^9+3=(7+1)^6+2{(7+1)^3}+(7+1)^3+3$
( by binomial theorem )
= $7m+1+2(7k+1)+7l+1+3$
=$7p+7$ which is a multiple of 7
A: By Euler theorem $2^6≡1 \mod 7$ thus:
$$2^{18} + 2^{10} + 1 + 2^9 + 2≡1+2^4+1+2^3+2\mod 7$$
which reduces to
$$28≡0 \mod  7$$
A: $$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}$$
