Puzzling Primes

Today I worked on some interesting applied exercises in the review of conics, as well as finishing a problem set in Analysis with an Introduction to Proof. I also spent some time thinking about a challenge problem that I found copied into one of my notebooks:

Problem of the Week #793 by Stan Wagon

A superprime is an integer (such s 7331) such that all of its left-to-right initial segments are prime. (For 7331, the segments are 7, 73, 733, and 7331, all prime.) There is largest superprime. Find it.1

I had done some work on the problem during one of my abortive stabs at doing math again. My approach was to try to prove that there is a largest superprime as a step toward constructing it. The work I did to that end is interesting, but I don’t know yet whether I can get beyond the place I got stuck before. Possibly finding the largest superprime empirically, then proving that it must be the largest would be more fruitful.

  1. To do. ↩︎

Rational-a-Rama

Today I will be sharing my proof that the decimal representations of rational numbers must repeat. This proof is based on a simple idea, but turned out to be pretty involved, with several parts.

The fundamental idea can be illustrated using long division. Consider the rational number $\frac{8}{7}$. We can find its decimal representation using the long division calculation below.

Long Division Remainders

Each step of this calculation begins with the remainder from the previous step (circled in red). Since the remainder on division by 7 must be an integer between 0 and 6, there are only 7 possible remainders. Thus, the remainder must repeat within no more than 8 steps. Once it repeats, the calculation will begin to cycle, causing the decimal representation it produces to repeat, as this one does.


Now let’s prepare for the more formal proof by proving two lemmas. I think the first of these is quite interesting and not immediately obvious. The second one is obvious, but I wanted to be assured of it, since it is vital to the main proof.

Lemma 1: Given a rational number $x$, if there exist two distinct digits $d_1$ and $d_2$ in the decimal representation of $x$ such that the sequence of digits following $d_1$ is the same as the sequence of digits following $d_2$, then the decimal representation of $x$ repeats.

Assume that two such digits exist and let the one which appears first be called $d_1$. Then the decimal representation of $x$ begins as follows: $s_1.s_2d_1s_3d_2$, where $s_1$ is a sequence of at least one digit and $s_2$ and $s_3$ are sequences of zero or more digits.

Now, since the sequence of digits following $d_2$ is the same as the sequence of digits following $d_1$, the decimal representation must continue: $s_1.s_2d_1s_3d_2s_3d_2$. Yet this further specifies the sequence of digits following $d_1$, so the same digits must appear again in the sequence following the initial appearance of $d_2$, yielding $s_1.s_2d_1s_3d_2s_3d_2s_3d_2$. This process (illustrated below) will continue infinitely, so $x=s_1.s_2d_1\overline{s_3d_2}$.

Thus, the lemma holds.

Two Digits With Sequences

(I realize the notation was a little sloppy here, with $d_2$ representing both a digit and a digit with its position, but I couldn’t find a good way to fix it.)

Lemma 2: Let $x$ be a non-negative rational number such that $x=\frac{n}{m}$, where $n$ and $m$ are non-negative integers and $m\neq 0$. There is no more than one way to represent $x$ as a mixed number $q\frac{r}{m}$ such that $q$ and $r$ are non-negative integers and $r<m$.

Suppose $\frac{n}{m}=q_1\frac{r_1}{m}$ and $\frac{n}{m}=q_2\frac{r_2}{m}$ where $q_1$, $q_2$, $r_1$, and $r_2$ are non-negative integers and $r_1,r_2<m$.

It follows that $q_1+\frac{r_1}{m}=q_2+\frac{r_2}{m}$ and thence that $q_1-q_2=\frac{r_1-r_2}{m}$.

Since $0<r_1<m$ and $0<r_2<m$, $-1<\frac{r_1-r_2}{m}<1$.

Thus $-1<q_1-q_2<1$, from which it follows that $q_1=q_2$, since $q_1$ and $q_2$ are integers.

Hence $\frac{r_1-r_2}{m}=0$, so $r_1=r_2$.

Therefore, both mixed numbers are the same, and the theorem holds.


Finally, we come to the main theorem.

Proposition: If $x$ is a rational number, then the decimal representation of $x$ repeats.

For any $x$, if the decimal representation of $x$ repeats, then the decimal representation of $-x$ repeats. Thus, it is sufficient to show that the theorem holds for all non-negative $x$.

Let $x$ be a non-negative rational number. Then $x=\frac{n}{m}$ for some non-negative integers $n$ and $m$, where $m\neq 0$.

The fraction $\frac{n}{m}$ can be expressed as a mixed number $q_1\frac{r_1}{m}$ such that $q_1$ and $r_1$ are non-negative integers and $r_1<m$. By Lemma 2, there is only one way to do this.

Using algebra we have: $$q_1\frac{r_1}{m}=q_1+\frac{r_1}{m}=q_1+\frac{r_1}{m}\left(\frac{10}{10}\right)=q_1+\frac{10r_1}{m}\left(\frac{1}{10}\right)$$

As above, the fraction $\frac{10r_1}{m}$ can be expressed uniquely as a mixed number $q_2\frac{r_2}{m}$ such that $q_2$ and $r_2$ are non-negative integers and $r_2<m$.

This yields $$q_1+\frac{10r_1}{m}\left(\frac{1}{10}\right)=q_1+q_2\left(\frac{1}{10}\right)+\frac{r_2}{m}\left(\frac{1}{10}\right)\text{.}$$

Notice that $q_2$ has only one digit, since $0\leq\frac{r_1}{m}<1$ and $0\leq q_2\leq\frac{10r_1}{m}$. Notice also that $0\leq\frac{r_2}{m}\left(\frac{1}{10}\right)<\frac{1}{10}$, since $0\leq\frac{r_2}{m}<1$. This means that $q_2$ is the tenths-place digit of the decimal expansion of $x$.

The algorithm can be continued as shown below, $$q_1+q_2\left(\frac{1}{10}\right)+\frac{r_2}{m}\left(\frac{1}{10}\right)=q_1+q_2\left(\frac{1}{10}\right)+\frac{r_2}{m}\left(\frac{1}{10}\right)\left(\frac{10}{10}\right)$$ $$=q_1+q_2\left(\frac{1}{10}\right)+\frac{10r_2}{m}\left(\frac{1}{100}\right)=q_1+q_2\left(\frac{1}{10}\right)+q_3\left(\frac{1}{100}\right)+\frac{r_3}{m}\left(\frac{1}{100}\right)$$ $$=q_1+q_2\left(\frac{1}{10}\right)+q_3\left(\frac{1}{100}\right)+\frac{r_3}{m}\left(\frac{1}{100}\right)\left(\frac{10}{10}\right)=q_1+q_2\left(\frac{1}{10}\right)+q_3\left(\frac{1}{100}\right)+q_4\left(\frac{1}{1000}\right)+\frac{r_4}{m}\left(\frac{1}{1000}\right)…$$ with $q_i\frac{r_i}{m}$ for $i>1$ always the unique mixed number representation of the fraction $\frac{10r_{i-1}}{m}$ such that $q_i$ and $r_i$ are non-negative integers and $r_i<m$. By logic similar to that above, when $i>1$, $q_i$ will always be a digit of the decimal representation of $x$, with its value given by the power of $\frac{1}{10}$ by which it is multiplied.

Since, for all $i$, $r_i$ is a non-negative integer less than $m$, there are only $m$ possible values of $r_i$. This means that, among the infinite values of $r_i$, there must exist distinct $r_j$ and $r_k$ such that $r_j=r_k$. (ETA: By the Pigeonhole Principle!)

Since the mixed number representations used by the algorithm are unique, if $r_j=r_k$, then $q_{j+1}=q_{k+1}$ and $r_{j+1}=r_{k+1}$. By induction, it therefore follows that $q_{j+h}=q_{k+h}$ for all $h$. Since, when $i>1$, each $q_i$ is a digit of the decimal representation of $x$, it follows by Lemma 1 that decimal representation of $x$ repeats.

Therefore the theorem holds.


I hope this makes some measure of sense. I had a lot of trouble making this proof lucid, and eventually I had spent too much time working on. Those whose eyes did not glaze over will note that the algorithm I employed here is essentially long division. In developing it, I did not set out specifically to reproduce the long division algorithm, and I was intrigued when I noticed they are basically the same. Here is our long division problem annotated to show the relationship:

Long Division

Never Do Today

Today I worked on exercises from both the review of conics and Analysis with an Introduction to Proof. I also thought some more about the questions from my post About Division. I’ve come up with a new argument that repeating decimals must represent rational numbers. It doesn’t require any theorems about geometric series, but it is going to be a bit of a pain to formalize. I may decide just to give an example of the maneuver it is based on and wave my hands for the generalization. Today I was going to share my proof that the decimal representations of rational numbers must repeat, but it is taking longer than I expected to write that up, so I will have to wait until tomorrow. Stay tuned, faithful readers!

Jiggety Jig

I’m back home after a wonderful trip. I only fit in a little math during my week away, but I did make some progress on the questions posed in my post About Division. I have developed a good argument that the decimal representations of rational numbers must repeat (or terminate, which is simply ending in a repeating zero). An argument that a repeating decimal must represent a rational number is proving more elusive. I could use facts about the sums of geometric series, but I feel as if there should be another way. More on these things later in the week; today I have a lot of neglected chores to do.

Ellipses

Today I did more exercises from the review of conics. Most of them concerned analyzing and graphing ellipses. It was still second year algebra all over again, but I was a little less bored than by the exercises with parabolas yesterday. I think I may have been bucked up by this intriguing 3Blue1Brown video about ellipses that happened to come up on my YouTube homepage last night:

I also did a little extracurricular reading today about the Goldbach conjecture and the related ternary Goldbach conjecture. The latter was recently proven by a mathematician called Harald Helfgott. I have not yet absorbed even the overall method of the proof, but I did understand that the abstract proof only applies to numbers greater than a constant $C$ that is very large in human terms yet small enough that all numbers less than $C$ can be checked by a computer. I thought that was interesting.

About Division

Today’s study time was devoted to more algebra review, including some problems that involved factoring using polynomial division. I have a vague memory of being taught polynomial division around the turn of the millennium, but I had heard the name more recently. There is debate these days about whether, in a society where almost everyone carries a calculator almost everywhere, it is still worth the instructional time to teach students numerical long division. (Eliminating it wouldn’t be unprecedented. I was never taught to compute square roots by hand, as older generations were.) At any rate, one of the arguments in favor of keeping numerical long division in the curriculum is that, without it, students won’t be able to do polynomial division. I’m not sure that would be much of a loss, honestly. It is a fairly niche method of factoring, and I managed to study a lot more math than most people without running into any other application of it. I think the greater drawback to eliminating long division would be that, without that tool to convert one to the other, the connection between fractions and decimals would become something mysterious only the calculator understands.

Speaking of conversion between fractions and decimals, in the portion of The Joy of X that I read last night, Steven Strogatz mentions the fact that the decimal representations of rational numbers always terminate or repeat. Of course, I wondered how one could prove that. I haven’t had time to work on it yet, but I think I can see the vague outline of how it might be done (probably using an argument related to the long division algorithm). The thing I don’t have any ideas about yet is how to prove that a number represented by a repeating decimal must be rational. I may find time to work on both of these tomorrow, but I may decide on more algebra practice instead. I am growing impatient to move on to a new review topic.

Squares as Sums of Odd Numbers, Part 2

Here is the promised geometric visualization of the fact that the $n$th square number is the sum of the first $n$ odd numbers. I hope it may be a bit more enjoyable for readers, who I know are mostly Olly well-wishers rather than math enthusiasts.

I actually developed this visualization between the first and second proofs I shared yesterday. As I knew the proof by induction would probably practically write itself, I got it out of the way first. I then moved on to look at the problem geometrically, hoping to gain insight that I could use to write a more illuminating proof. This geometric approach turned out to be more closely related to the proof by induction than to the second proof I came up with later, though.


Claim: The $n$th square number is the sum of the first $n$ odd numbers.

First of all, how would we represent a square number visually? One way is as a collection of dots arranged in a square, as shown below.

Visualizing Squares

Second, how can we represent an odd number visually? Well, every odd number is one more than an even number, and any even number, being divisible by 2, can be represented as two rows of the same number of dots. Thus, an odd number can be represented as two rows of the same number of dots, plus one more. (Except for 1, which is simply 1 dot.)

Visualizing Odds

Now imagine rearranging each odd number into an L shape as shown below. These L-shaped figures also have two rows of the same number of dots, plus one more.

Rearranging Odds

Next, notice how the series of L-shaped figures representing the odd numbers nest together to form a square.

Nesting Odds

Thus, the claim holds at least up to $n=5$. To draw a square representing the next square number, you would add a row and a column to this square, which you can see would be the same as adding another L-shaped figure representing the next largest odd number. So the claim must hold for each higher $n$ as well.


I also played around with a similar visualization using even numbers. The L-shaped figures representing odd numbers can be adapted to instead represent even numbers by removing the dot in the corner. When you do that, the nested figures look like this:

Nesting Evens

The center diagonal is missing from each square. Since it contains a number of dots equal to the side length of the square, the number of dots left in the $n$th square is $n^2-n$.

Accounting for the fact that the first even number, 2, corresponds to the second square, this leads to the formula

$$\sum_{i=1}^n2i=(n+1)^2-(n+1)=(n+1)[(n+1)-1]=(n+1)(n)\text{.}$$

This is what you would expect given the well known formula for the sum of the first $n$ natural numbers and can also be proven by induction. I also checked the sum of this formula and the one from yesterday. The sum of the first $n$ odd natural numbers plus the sum of the first $n$ even natural numbers should equal the sum of the first $2n$ natural numbers, which it does.

$$n^2+(n+1)(n)=n[n+(n+1)]=n(2n+1)=\frac{2n(2n+1)}{2}$$

Squares as Sums of Odd Numbers, Part 1

Today was a fruitful day for math. I watched more of the Essence of Calculus series, did a couple of pages of algebra review exercises, then started on the book The Joy of X by Steven Strogatz, which I bought earlier in the week. Near the beginning of that book, the author mentions that the $n$th square number is the sum of the first $n$ odd numbers. I stopped reading at that point and went to see if I could prove the claim. I was able to come up with two proofs, as well as a way of visualizing the problem geometrically that led me to a formula for the sum of the first $n$ even numbers. I also checked that the sum of the two formulas yielded the well known one for the sum of the first $n$ natural numbers, which it did.


Proposition:
$$\sum_{i=1}^{n}(2i-1)=n^2\text{ for all }n\in\mathbb{N}\text{.}$$

The proof by induction is easy…

Proof 1 (by induction):

When $n=1$, $\sum_{i=1}^{n}(2i-1)=\sum_{i=1}^{1}(2i-1)=2(1)-1=1=1^2$.

Assume that $\sum_{i=1}^{n-1}(2i-1)=(n-1)^2$.

It follows that $\sum_{i=1}^{n}(2i-1)=\sum_{i=1}^{n-1}(2i-1)+(2n-1)=(n-1)^2+2n-1=$ $(n^2-2n+1)+2n-1=n^2$.

Therefore, by induction, the proposition holds for all $n\in\mathbb{N}$.

Proof 2:

For any $n\in\mathbb{N}$, $\sum_{i=1}^{n}(2i-1)=[2n-1]+[2(n-1)-1]+[2(n-2)-1]+…+[2(1)-1]$.

Since there are $n$ terms in the sum, there are $n$ instances of $-1$.

Thus, $\sum_{i=1}^{n}(2i-1)=2[n+(n-1)+(n-2)+…+1]-n$.

Using the well known formula for the sum of the first $n$ natural numbers, it follows that $\sum_{i=1}^{n}(2i-1)=2[\frac{n(n+1)}{2}]-n=n(n+1)-n=n[(n+1)-1]=n^2$.

Thus, the proposition holds for all $n\in\mathbb{N}$.


Stay tuned tomorrow for a geometric visualization of the problem and the formula for the sum of the first $n$ even numbers.

Squares as Products of Squares

While watching a video about factoring, it occurred to me that, if n is a square number, then n is also the product of square numbers. This is trivially true, of course, in that n is the product of itself and 1, which is a square. If the root of n is not a prime, though, then n can be expressed as a product of squares in at least one other way. To see why this is, consider 36:

36 = (6)(6) = (3)(2)(3)(2) = (3)(3)(2)(2) = (9)(4)

Given any factorization of the root of n, n can be expressed as the product of the squares of the root’s factors.

This is all pretty obvious, but I thought it was interesting. In the future, I may consider if there is a geometric interpretation of this fact and what light it might shed.1

  1. To do. ↩︎