An interesting math puzzle

A palindrome is something that reads the same forward or backward (ABBA, 12321).

Starting from 1 , if you write all consecutive numbers together till n, can you ever form a palindrome ?

For example, for n = 11

the sequence is 1234567891011 which is not a palindrome.
Does such a n exist ?

My gut answer is No.

For one thing, the center or centers of this sequence would have to be a palindrome itself.

But, someone can give a proper logical answer.

Yes. How about n=1?

I doubt any other value of n works.

I suppose I could try testing it algorithmically. Let me see if i can do a program and keep it under O(n^2) time. :smiley:

My mistake. One stipulation is that n!= 1

Algorithms are a bad way to show that something doesn’t exist. You tested up to n? Maybe the first counterexample is n + 1.

If you could write such a palindrome, you could write a shorter palindrome by taking off the first and last digits, and so on and so forth. This is not enough in and of itself to cause a problem, but could lead to something interesting down the line.

If you’re allowed to start from 0, you can do it in binary: 0, 1, and 10 make 0110, a palindrome. I can’t find one in base 3, but I didn’t try for very long.

Might also be interesting to see how this works outside of positive integer bases–what about the Cantor or Fibonacci representations?

Let me trot out my Turing machine T[subscript]q[/subscript] which is designed for this and I’ll let you know when it halts on this particular question…

Are you ppl telling me this cannot be solved analytically ?

Gyan9 -

Hm, how about this:

N can only have 9 possible values:

1
21
321
4321
54321
654321
7654321
87654321
987654321

Why? Because the end of your sequence HAS to be in ascending order when read backwards for you to get a palindrome.

Assuming that we ignore the trivial case of N=1 :slight_smile: we are left with 8 possiblities.

Every single one of these breaks down when you look at the end of the sequence:

N=21

123…192021

N=321

123…319320321

N=4321

123…43204321

N=54321

123…5432054321

N=654321

123…654320654321

N=7654321

123…76543207654321

N=87654321

123…8765432087654321

N=987654321

123…987654320987654321

QED

(Bows for applause unless glaring errors are noticed)

And to show that N can’t be anything other than those 9 values, try anything else, again remembering that the digits must be in descending order which really limits the values of N that you have to look at…

N=10987654321

Fails by inspection, just read it backwards and you’re hosed when you hit the 0. And since any higher value of N (1110987654321 for example) still contains 10987654321, which we know fails the palindrome test, you are stuck with the original 9 possible values of N.

What about n = …211101987654321 ? Where … represents some suitable numeric prefix ?

Very nice Valgard

Valgard, you’re way off. The last “21” could be the billionth and (billion-plus-one)th digits.

Just typing this up when Gyan posted:

Ok that’ll teach me to get all giddy:

My example on the “expansion” was wrong, N=1101987654321 would be a possibility (read backwards you get 1234567891011).

However so far as I can see (no, not a cast-iron proof) all the sequences will break down at a point: N has J digits in it, and the (J+1)th digit from the end must be a 0 (since N ends with 1, the number right before it ends with 0), and that 0 still hoses the sequence.

Drat.

Unless the J+1th digit from start is a 0.

In any case, there must be an analytical way to sort this out. After all, it was asked in a Russian Mathematical Olympiad.

Certainly, however I was looking at the “backwards view”, checking the end of the sequence in reverse to see whether it can possibly stay in ascending order.

Math Olympiad? OK, now I don’t feel so bad about messing it up :slight_smile:

You stopped too soon in base two, ultrafilter. Start with 1 and count to 3 in base two: 11011

That’s a palidrome, just what the OP was asking for. n = 3 but is represented in base two.

(Sheepishly subdued tone now)

(And please tell me if it’s uncool to “think out loud” in a GQ math puzzle)

The number of digits in N (call it J) is far smaller than the number of digits in the written sequence 123…(N-2)(N-1)(N).

For example with N=21, J=2 (digits) and when you write it out you get 33 digits (call that K). Wtih N=321, J=3 and K=425 (quickie calc, I may be off but it’s still way bigger than J is).

If we can show that the end of the sequence goes into a pattern not found at the beginning of the sequence we’re in good position to show that the total sequence is not a palindrome.

Pick an abitrary N. It ends in 1 for reasons previously shown. Thus the (J+1)th digit from the end of the sequence must be a 0. Example:

N=654321 (J=6)

End of the sequence is …654320654321 and the 7th digit from the end is a 0.

After this the sequence immediately starts back into ascending order from 2 on up.

Here’s where it gets fun; I can SEE what I need to prove but I’m missing that one little key bit. The rough line of reasoning is that because the J digits from the back end are all in sequence, and J is so much smaller than K, this interruption in the sequence (where we hit 0 and then start counting upwards again at 2, 3, 4…) occurs nowhere near the middle of the overall sequence. The middle of the sequence, where the increasing and decreasing sets of numbers smack into each other, is the only place where you can possibly find that interruption, correct?

So that’s where I am now. Can anyone follow this line of reasoning? How best to administer the coup de grace?

Does this work?

Suppose that the list 1,2,3,…,N produces a palindrome P when the commas are removed. Let 10^m be the largest power of 10 less than or equal to N (we can know that m >= 2 by explicitly checking a finite number of examples). Then the string of m 0’s in the decimal expansion of 10^m can be the only string of m zeros in P. Therefore, it must be in the center of P. But this string of m zeros will be immediately preceeded by the digits 9 1 (from the 9 at the end of 10^m - 1 and the 1 at the beginning of 10^m) and immediately followed by the digits 1 0 (from the digits at the beginning of 10^m + 1). Since 9 1 is not 1 0 in reverse, P cannot be a palindrome. QED

Incidentally, if my proof is right, I think it works for any base greater than 2.

I think you’re on the right track, but there’s at least one hole you need to patch up:

2 × 10[sup]m[/sup] has the same number of consecutive 0’s as 10[sup]m[/sup].