# The Challenge

Ok, I’m swamped at the moment but I wanted to post something involving *Latex* because I’ve been intending to add it to my blogging skill set. I had planned to discuss my favourite problem but that will have to wait until later. For now this is quick and dirty (while still using *Latex*. Hooray!)

Today a colleague sent me a link to Everything is Mathematical. It’s not a resource site, because at the moment there’s only one video. What it is is a well presented mathematical puzzle/competition site. If you’re in the UK, you can submit answers to the posed problem and win a prize. I’m not in the UK, but the site will still be useful.

There’s only been one problem so far. I’m really impressed by the way Marcus du Sautoy presents the problem in an easy-to-understand way. There’s no pseudocontext here, there’s no anyqs. It’s all theory but I still think it’s great to show any class ranging from middle schoolers to upper highschoolers. The presentation is great, the challenge is easy to understand and adaptable. I’m **REALLY** looking forward to what comes next.

# The puzzle

The challenge is this:

My paraphrasing is this:

Palindromic numbers read the same forwards and backwards. So, 414 is a palindromic number, so is 1234321

It’s pretty easy to write down all the 2-digit palindromic numbers:

- 11
- 22
- 33
- 44
- 55
- 66
- 77
- 88
- 99
The question is,

how many palindromic numbers are there that have 351 digits?

And, what’s the smallest difference between the two closest ones?

So, I thought I’d have a go at cracking the problem, publishing my solution and exercising my newfound Latex skills. I’m not completely sure I got it right so feel free to correct me in the comments. I’m not sure how (or if) I’ll show this to my students yet, because time is tight this time of year. But I’ll work something out.

# The Solution

Anyway, we start with the pattern, and what Du Sautoy gives us. There’s 9 numbers that are 2 digit palindromes. For each of those, we can add 10 digits in the middle (0…9) to give us three-digit palindromes, so there are 90.

For four-digit palindromes, we start with our same two-digit palindromes (9 of them). Now we add two digits into the middle but those two digits must be the same. This means once again there are 90.

For five-digit palindromes, we start with our three-digit palindromes (90 of them) and we can insert one of ten digits into the middle. This gives us 900. The comparison of 6-digit to 5-digit is the same as 4 to 3. That is, we add two digits but they must be the same, so we’ll end up with 900 again.

The pattern becomes obvious pretty quickly

- 2 digits – 9 palindromic numbers
- 3 digits – 90
- 4 digits – 90
- 5 digits – 900
- 6 digits – 900
- 7 digits – 9000
- 8 digits – 9000

This pattern is if d is even or if d is odd. (You nerds out there, tell me if there’s a better way of writing different-but-related odd/even functions)

So substituting into gives

That’s 90,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,

000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,

000,000,000,000,000,000,000,000,000,000,000 numbers.

How far apart are the closest ones? Well, if we change any number in the first 175 digits, we have to make one on the symmetrical digit. The only way we can change just one digit is if it’s the middle one. In a more simple situation, lets look at some five digit numbers.

- 55155
- 55255
- 55355
- 55455

These numbers are all 100 apart, and there are no two 5-digit palindromic numbers closer together than that. Even considering going across a place-value column, the closest I can come up with is (for example) 55955 compared to 56065. These have a difference of 110, so it’s not helping us get closer to our target. (Hopefully you would have realised by now, **this is not a proof**. I don’t have a proof for this).

So assuming the closest difference occurs when we change the middle digit by one, a 351 digit number has a middle digit in the 176th column. Thus the smallest difference is

# The Extension

One thing I love thinking about is how maths works in different numerical bases. If we’re dealing with base-3, for example we can only use digits 0, 1 and 2. How many two digit numbers are there? Two. 11 and 22. Three Digits? 101, 111, 121, 202, 212, 222 so **6**

This means our rule for how many d-digit numbers in a base-3 number system is if d is even or if d is odd.

In a base-n number system, this generalises to if d is even or if d is odd.