# Alphametics puzzle, given numbers that are prime and square.

I have been trying puzzle solving recently and came across this problem (sorry if this is not entirely appropriate on a maths stack exchange, I have also posted this on the puzzle one).

Any hints on how to do this?

So far, I have found that N, R and F must be odd (as they are the last digit in a 5 digit prime number), and that N must be specifically either 1,5 or 9, because all square numbers end in either 1,4,9,5 or 6, and N can’t be 4 or 6, because it must be odd. Finally, I think E must be even because N-E=R, and since N and R are odd, E must be even.

However, these observations don’t seem to be getting me anywhere.

• $U$ must be $0$ if $N < E$ or $9$ if $N > E$, because it is the result of $E - E$ with a possible borrowing. Also, $N$ can't be $5$, because $SEVEN$ would be divisible by $5$. Aug 23, 2019 at 15:30
• Notice $N$ can't be $5$ because $SEVEN$ is prime. Aug 23, 2019 at 15:33
• @eyeballfrog Do you have the inequality reversed? If $N>E$ then $R=N-E$ and $U=E-E=0.$ Aug 23, 2019 at 15:41
• @saulspatz Yes I do. Aug 23, 2019 at 15:47
• Since $SEVEN-THREE=FOUR$ we must have $S=T+1$ or the difference would have $5$ digits. Then $TEN$ is a three-digit square, with $3$ different digits, ending in an odd number, whose first digit is not $9$. I can't think of anything better than to test each case. For example, the smallest possibility is $TEN=169,$ which leads to $SEVEN = 26V69,$ which is not possible, by examination of a table of primes. Aug 23, 2019 at 16:03

From your reasoning, we know that $$N$$ is $$1$$ or $$9$$. If it is $$1$$, then $$U$$ is $$9$$, and if it is $$9$$, $$U$$ is $$0$$, because $$U$$ is a result of the $$E-E$$ with possible borrowing from $$SEVEN - THREE$$. This means no other letter can be $$9$$.

We know that $$S = T+1$$ and $$H > E$$, because there had to be a borrowing to get a four-digit number. Since none of these letters can be $$9$$, we know that $$E$$ and $$T$$ also can't be $$8$$. The condition that $$TEN$$ is a square, leaves $$169,361,529,729$$. However, in the last case, $$R = N-E$$ would be $$7$$, not distinct from $$T$$, and in the second case, $$R = 10 + N - E = 5$$, making $$FOUR$$ divisible by $$5$$. So $$N = 9$$, $$U = 0$$, and $$TEN = 169,529$$. This means $$SEVEN$$ is either $$26V69$$ or $$62V29$$. However, in the first case, that would mean $$16 - H = F$$, but that's not possible as they must be distinct and neither can be $$9$$ (there can't be a borrow because $$R = 3$$ and $$1$$ and $$2$$ are already taken as values for $$V$$). So $$SEVEN = 62V29$$.

So $$SEVEN - THREE = FOUR$$ is now $$62V29 - 5H722 = FO07$$. We know $$F + H = 11$$ or $$F + H = 12$$, depending on whether there's a borrow. Since $$RUOF$$ is prime and the only odd digits left are $$1$$ and $$3$$, $$F$$ must be one of them, but it can't be $$1$$ and satisfy either equation. So $$F$$ is $$3$$. $$H$$ must then be $$8$$, because $$9$$ is taken. Thus, there must have been a borrow in $$V - 7 = O$$, which is satisfied by $$V = 1$$, $$O = 4$$.

Thus, $$SEVEN - THREE = FOUR$$ is $$62129 - 58722 = 3407$$ and checking the prime table shows $$62129$$, $$3407$$, and $$7043$$ are indeed prime. Meanwhile, $$TEN = 529 = 23^2$$ is a perfect square, as desired.

As a fun aside, $$FOURTEEN$$ is prime but $$SEVENTEEN$$ is not.

EDIT: removed reliance on prime table.

• So in the puzzle, the information that $RUOF$ is prime is superfluous, correct? Aug 23, 2019 at 16:28
• @saulspatz it eliminated $F = 8$. Aug 23, 2019 at 16:29
• So it did. Thanks. Aug 23, 2019 at 16:30
• @saulspatz it turns out the prime table isn't necessary. see edited answer. Aug 23, 2019 at 16:35
• Elegant solution. +1 Aug 23, 2019 at 16:52