# My library membership number

My library membership number, which I readily forget, is a 10-digit number, all different digits. However, I do remember it is the largest such number in which any block of four adjacent digits is either a prime or a perfect square.

What is it?

(Preferably no computers except to find list of squares and primes)

• Are you absolutely certain that there is such a number? I ask because (1) I think I have a proof that there isn't and (2) a computer search (conducted in such a way as to avoid showing me the answer if it succeeded) didn't find one. I am extremely fallible so despite #1 and #2 I think the error is probably mine, but could you double-check anyway? Thanks. Oct 21, 2022 at 15:03
• You are right. My alleged membership number with the property I describe is no such. Sorry! Oct 21, 2022 at 15:33
• If you would like to adjust the question to ask whether there is such a number or not, I can tweak my part-written answer to explain why the answer is no :-). Oct 21, 2022 at 15:36
• (But I think we have found the explanation for why you "readily forget" the number.) Oct 21, 2022 at 15:36
• (I posted my answer anyway. I know I was there first :-).) Oct 21, 2022 at 18:08

The number

does not in fact exist.

Explanation:

The digits 0, 2, and 8 can't be at the end of any block of 4 since no 4-digit prime ends with any of them, no square ends with 2 or 8, and any square ending 0 actually ends 00. So 0,2,8 (in some order) are the first three digits, the only ones that don't end any 4-digit block.

Now

Let's think about the 4-digit square ending in 5. Obviously this must be a square since no 4-digit prime ends in 5. Any 4-digit square is the square of a 2-digit number between 32 and 99; this one must be the square of 35, 45, ..., 95. These squares are 1225, 2025, 3025, 4225, 5625, 7225, 9025. The only ones without repeated digits are 3025 and 9025. But these are impossible because each of them has a 0 appearing after a non-{0,2,8} digit.

• Since the squares of ?5 end in 25 then the first 4 digits must be 8025. Oct 22, 2022 at 12:45
• Yes, that's another nice way to do the last bit. Oct 22, 2022 at 13:46

No such number exists.

All digits in the resultant number starting from the $$4^{th}$$ number must be the end of some "block".

Primes can end with any odd digit, and out of the even digits, perfect squares can end only with $$0$$, $$6$$ and $$4$$. But even $$0$$ is not possible, because only for multiples of $$10$$ the squares end with a $$0$$, which means the square must have atleast $$2$$ zeroes at the end, but that would break the all distinct digits condition.

So the digits $$0$$, $$2$$ and $$8$$ cannot be the end of some block so these must be the first $$3$$ digits in some order. Let us try all paths we can take in decreasing order and see if we can reach a number. Basically we should choose the next digit such that last $$4$$ digits form a prime/perfect square and the digits are all distinct.

820 -> 8209 -> X

802 -> X

280 -> 2809/2803/2801
2809 -> 28093 -> 280937 -> 2809371 -> X
2803 -> 28039 -> 280397 -> X
2801 -> 28017 -> 280179/280173
280179 -> X
280173 -> X

208 -> 2089 / 2087 / 2083 / 2081
2089 -> X
2087 -> X
2083 -> 20839 -> X
2081 -> X

082 -> 0829 / 0827 / 0823 / 0821
0829 -> 08297 / 08293 / 08291
08297 -> 082971 -> X
08293 -> X
08291 -> 082917 / 082916
082917 -> 0829173 -> X
082916 -> X
0827 -> 08273 -> 082731 -> X
0823 -> 08237/08231
08237 -> 082371 -> 0823719 -> X
08231 -> X
0821 -> 08219 -> X

028 -> 0289 / 0283 / 0281
0289 -> 02897 -> 028971 -> X
0283 -> 02837 -> X
0281 -> 02819 -> X

All paths end with a dead end which indicates there isn't a valid number satisfying the conditions. Assuming I did not end up with a mistake at any step.