Posted on 02 Aug 2021 by Steve Markham

Math with Straingers

On the train ride to Provo from Salt Lake City, Kyle struck up a conversation with a stranger about the YouTube videos of Magic he was watching. Once he found out how nerdy we are, he asked us a math puzzle that had stumped him for 6 months: Find a number where if you swap the first and last digit, you get twice the value.

My immediate intuition was “provably impossible” and after a minute of thought I said that out loud. Kyle had it proved within a few minutes. The strainger sent me a link to the original source, and it turns out he misremembered it. I hope the guy hadn’t been losing sleep for six months, because the real puzzle is *hard*, but doable: Find the smallest positive integer where if you move the last digit to the front, you get twice the value.

Spoilers below.

There are two approaches, one algebraic, and one intuitive. Let *a* be an n-digit integer, and *b* be a single digit integer. Then we seek an (a,b) such that 2*(10*a+b)=10^n*b+a, or equivalently, 19*a = (10^n-2)*b. That implies that a = b*(10^n-2)/19, and since b is a single digit and a is an integer, 10^n-2 must have a factor of 19 in it.

Kyle discovered his own method for finding such a *n*, but I used what I call “short division” which looks like long division, except you don’t write out the products below, you just right the difference after subtraction as a tiny superscript. What are we dividing? Well, divide 19 into a bunch of 9s until you get a remainder one. Then, instead of adding another 9, you change that last 9 into an 8, and that means 19 goes in evenly. So, 19 goes into 99 five times, remainder 4; it goes into 49 twice, remainder 11, it goes into 119 6 times, remainder 5, etc. The punchline is that 19*5,263,157,894,736,842=99,999,999,999,999,998. Yeah, I know, that number is much larger than I expected. It seems like we’re almost done, with *b*=1 and *a*=5,263,157,894,736,842, but 99,999,999,999,999,998=10^*17*, and that *a* is only 16 digits. Recall that we stipulated *a* must be n-digits. But, we can easily add digits by using *b*>1. The smallest value that works will be when *b*=2, but any value of *b* will work.

The intuitive method works faster, but it’s harder to know for sure that it’s the smallest value. In this method, we simply assume that the last digit is a 1, and then see what that implies. Suppose our number is XYZ1; then twice the value is 1XYZ. Thats means Z=2, since when we double the 1 in the ones place, we’ll get 2 for sure. By similar logic, doubling a 2 in the tens place gives Y=4, and X=8. Moving leftward through our number, 8 will double into 16, but we only write the 6 and carry the 1. Double 6 gives 12, but we carried a 1, so we write 3 and carry a 1 again. Then 7, then 4, then 9, then 8, then 7, then 5, then 1, then 3, then 6, then 2, then 5, then 0, then 1. At this point the sequence repeats itself, and that is a clue. So we have 1052631578947368421. If we drop the leading 1, then we are left with a number that, when you move the 1 from the back to the front, it doubles in value. BUT, dropping the 1 in front requires leaving a leading 0 in front, which is weird. However, the double value will be the *b*=2 value from our original method, namely 105,263,157,894,736,842. And that does indeed look like something that, when doubled, will start with a 2, and in particular will be 210,526,315,789,473,684 (which is *b*=4).

We can find *b*=4, or 8 by doubling. But we can also find *b*=3 by simply cycling hrough the numbers until it ends with a 3. And there are *2* of those, but the smaller one is the 3 followed by the one, 157,894,736,842,105,263; the other one starts with a 6, and will have a carried 1 in front instead of a 3, when it is doubled.

Tagged with: geek

Comments are closed for this post.