## Summing 1 + 11 + 111 + … and My Problem Solving Technique.

### September 17, 2011

This post was inspired by a question on the comment second of my last post about the prime-ness of 111…111. The question is: what’s the sum of 1 + 11 + 111 + … + 111…111? This seemed kind of silly to me (especially if the sum has less than 10 terms) but I quickly realized that I couldn’t figure out a "closed form" without appealing to weird "carry" tricks. So I tried to figure something else out.

Because my final solution to this question was somewhat unsatisfying, I’ve made this a special kind of post! This post will have two main purposes: to try to answer this question and to show what kinds of things I do when I don’t know the answer to a problem. So let’s begin.

**First, **I scribbled out lots of examples to see if there were patterns in the numbers. Indeed, there are, but there was no nice way to describe them in general without creating a whole lot of variables and expanding the number of terms out into a base-ten sum. This was frustrating. Especially because I knew there might be an easy answer looming out there that I wasn’t clever enough to see.

**Second,** I noted that 11 and 111 and 1111 are kind of weird numbers; written in base 10 they look pretty, but they don’t have much else in common. As we saw in the last post, a few are prime but many are not, and many have very strange prime factorizations — these factorizations do group together, but that seemed to be too far away from this problem to use. So, maybe another base would make them better formed? I plugged away in wolfram alpha. The first two bases I tried were base 2 and base 11. Neither one worked nicely. When I tried base 5, I found that the numbers followed an interesting pattern:

were mapped to

Note that the last few digital always stay the same here. Because the decimal form of these numbers is 1 + 10 + 100 + 10000 + … this is not all that surprising. We’re essentially adding the base-5 versions of these together. Note that means the number 400 in base 5; in decimal this is the number 100. So . We drop the in our base 10 numbers and note the following:

and while this seems to have a bit of a pattern, it grows too fast to be of use for adding. On the other hand, I found that base 5 can be fairly neat when you input numbers that have "nice forms" in base 10. Try it out!

**Third, **I was a bit upset, so I went back to thinking that I could write the number of terms as and some some mods to figure out the digits. The first digit will be easy: it’s just . But then what’s the carry? After a bit, I worked out that it will just be . This did not seem to be going anywhere, since this number might be somewhat large too; we would need to add this number times, and then there’s another carry that will look significantly more complex than the one I just wrote. After trying this for five carries, I started to lose track of what I was doing; the formula was getting much more difficult than just doing "normal" addition. This clearly wasn’t going to go anywhere. At this point, a flash of insight hit me. Of course. This is just like adding 1 + 10 + 100 + 1000 + …, but only a *little bit off*. But how much off?

**Fourth,** I thought that, okay, 1 + 11 + 111 + 1111 +… is the same sum as 1 + 10 + 100 + 1000 + … with a difference of exactly 1 + 11 + 111 + … with one less term. If there are terms in the original, then it is equal to with terms plus with terms. Note, then, that if we define the term to be the sum of terms that look like , then we have . At this point, I began kicking myself, because this tells me nothing new about the problem; in fact, it is essentially a restatement of the problem! But because of this, I thought about what happens when we do addition in 10’s. I realized that it is exactly the same sort of thing we are doing when we add 11’s, but each successive digit will raise by 1. So for example, while

1 + 10 + 100 + 1000 + 10000 = 11111

we have

1 + 11 + 111 + 1111 + 11111 = 12345

Each digit, starting at the left, is one plus the one before it. Of course, this suggests a pattern. But then what happens when you get far enough along?

which does not look as pretty. But look; if we add in the following way, this becomes easy! (I’ve attempted to use a chart to display place values.)

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |||

1 | 0 | ||||||||||

1 | 1 | ||||||||||

1 | 2 | ||||||||||

+ |

1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 0 | 1 | 1 | 2 |

Which is exactly what we got above! Note here that I’ve made a "10" that sits inside the tenth decimal place (and so is implicitly a carry of 1 in the ninth place) and a "11" that sits in the tenth place (and so is a carry of 1 in the tenth place and 1 in the eleventh place) and so on. I’ve found that this method of computing is slightly faster than computing the original sum by hand and much less space consuming. Unfortunately, the clever (and even not-so-clever) reader will notice that this is still the sum of terms. Though I find it faster because you are only adding at most three things in each column (carries included). I tried to speed-test myself by adding together 20 terms this way and by doing 1 + 11 + 111 + … etc. straight out. My times are as follows:

Original Way (Adding 1 + 11 + 111…): 1 minute.

New Way (Described above): 40 seconds.

I also was much less confident doing this the original way (try it; you’ll have to keep track of the carry and the number of ones you need to add up and that gets confusing). The most time consuming part about the "new way" was writing out the problem; I did not count this in the "original way" because it’s just as easy to visualize the problem as it is to write it out — it would take significantly longer. If I were to only time the "calculation" part, the new way took me about 15 seconds. Pretty good for a human.

**But, **this solution was the best I could do. I do not have a closed form. If anyone has a different or more interesting solution, let me know. I didn’t want to resort to asking google, but maybe there’s a cute trick that makes this into a nice closed form. I’m not sure.

**Edit: **Of course, there is an easier solution which was provided to me by Josh "The Widowmaker" Silverman over at his blog. The key was to represent this as a geometric series (something that I seem to have completely missed out on). It turns out that the closed form expression is

for the sum of the first numbers of this form. To see the derivation, go to his blog and read it over.

## An Elementary Continued Fractions Problem.

### September 7, 2011

To celebrate the 15k people who have, for whatever reason, happened upon this blog, I thought I’d post about something kind of fun. I was going through some of my older books to try to see what I could give away, and I happened upon the sequence

which should look familiar to you. Something kind of fun and mean to do is to tell someone who doesn’t know much math to evaluate this. After they’ve had some time to get frustrated, you note that if we let

then then the original fraction is just . Of course, this has an easy solution; , or which is known as the golden ratio. Similar looking "regular" continued fractions can be computed similarly.

For ease of notation, I will say when I mean

which is standard notation. Note the semi-colon. This means the golden ratio is .

It’s kind of neat to see what kinds of things you get with things of the form where I have purposely used here to hint that even complex values may be used. Try out a few values. Here’s a list of things to try:

- Try to get a rational number.
- Try to get a purely imaginary number. Is it possible?
- What kinds of numbers will give you rational numbers? (There is actually a theorem about this!)
- Can you ever obtain 0? Why not? Is it obvious from how we construct ? It it obvious from the solution to the quadratic?
- (Something I haven’t tried yet!) Do any complex numbers give you real numbers? Do any complex numbers give you rational numbers? (After reading below, is analytic? What does it look like in the complex plane?)

The nice thing about this problem is that it is actually accessible for a student in high school who has seen the quadratic formula!

A little edit below, WITH PICTURES!