The Magical 1 and 42

I stumbled upon a really cool mathematical anomaly that is easy to understand and can be appreciated by almost anyone.

The game begins by starting with any whole number greater than zero. To illustrate, let’s choose my birth year of 1977.

Now, we will create a sequence from this number in the following way.

Add up the square of the digits of your number for the next number in the sequence.

Since 1^2+9^2+7^2+7^2 = 1+81+49+49=180, this is the next number in the sequence.  The next number?  Well, 1^2+8^2+0^2 = 1+64=65, so 65 is the next number in the sequence.  Here are the next several:

  • 6^2+5^2=36+25 = 61
  • 6^2+1^2 = 36+1=37
  • 3^2+7^2=9+49=58
  • 5^2+8^2=25+64=89
  • 8^2+9^2=64+81=145
  • 1^2+4^2+5^2=1+16+25=42

42!  I got to 42!

Can you believe that if you form sequences in this manner, every number will either end at 1 or at 42?  Indeed, about 14-15% of the whole numbers will end at 1, while the other 85-86% will end at 42.

Try it for yourself!

To be a little more precise, there is nothing special about 42.  You could name any of the following numbers that result from 42 coming back to itself:

  • 4^2+2^2=16+4=20
  • 2^2+0^2=4
  • 4^2 = 16
  • 1^2+6^2=1+36 = 37
  • 3^2+7^2=9+49=58
  • 5^2+8^2 = 25+64 = 89
  • 8^2+9^2=64+81=145
  • 1^2+4^2+5^2=1+16+25=42

About 85-86% of the whole numbers will get trapped in this loop.  But 42 is the coolest, since it is the answer to the great question of Life, the Universe, and Everything. Perhaps we’ve stumbled upon the great question?

If you create a sequence beginning with any whole number greater than zero by adding up the squares of the digits of the number each time, what number other than 1 will the sequence converge to?

For a fun example of one that converges to 1, let’s go with my high school graduation year of 1995:

  • 1^2+9^2+9^2+5^2=1+81+81+25=188
  • 1^2+8^2+8^2=1+64+64=129
  • 1^2+2^2+9^2=1+4+81=86
  • 8^2+6^2=64+36=100
  • 1^2+0^2+0^2=1

Want to take this challenge to an extreme level? Try Problem 92 on Project Euler.

Mathematical Scavenger Hunt

Every Fall semester a colleague and myself develop a mathematical scavenger hunt for several competing high schools that come to visit our campus. This year, we chose the story “Ready Player One” as a theme with a final puzzle modeled from The Magical Labyrinth, a 2009 award winning game that involves a hidden maze of walls.

First, our students were provided instructions to go retrieve several numbers from campus. This year they had to visit and retrieve numbers from the following sites:

  • Ben Franklin statue on the south side of the Law School Building had b1=2 birds, b2=13 vest buttons, and b3=8 fastened vest buttons.
  • The Vietnam Memorial just southeast of Morgan Hall had r1 = 5, r2 = 2, and r3 = 0 names that began with the letter “R” in the first column, second column, and third column of the plaque, respectively.
  • The four walls that were around Carole Chapel on campus had varying number of bricks along the tops of them. These were B1 = 13, B2 = 5, B3 = 12, and B4 = 17, respectively.

Each of the several schools were directed to a Registration Page, created by the esteemed Dr. Mechtly in CIS.  Once they registered and typed in a registration passcode, they were advanced to the Tomb of Horrors.

Tomb of Horrors

Here students were given that the area of the region below is 62 and that they needed to solve for x using the numbers they found for b1, b2, and b3.  It also helps to know that the angles a are both the same.

MathDay2018Problem2Pic

Once x was solved for and correctly entered, the team was awarded the Copper Key. The top five teams were awarded a physical replica of the Copper Key from the movie.  They were then taken to Zork.

Zork

Here students were trying to find a specific Pythagorean triplet. The most famous triplet is (3,4,5). These triplets satisfy the equation 3^2+4^2=5^2 and can be represented as side lengths of right triangles.

Beginning with the three numbers 33, 44, and 55, students were instructed to add or subtract the numbers they found for r1, r2, and r3 from or to these numbers in some way (not necessarily in that order) to create a Pythagorean triplet.  For example, you could subtract r3 from 33, add r1 to 44, and subtract r2 from 55 as a possible check (but this wouldn’t work).

Once you find the Pythagorean triplet (x,y,z) in order so that x<y<z, then you were to use the values a = -2, b = -1, and c = 3 that were given in the Zork room and enter the linear combination ax+by+cz correctly to receive the Jade Key and advance to the Syrinx room!

Syrinx

In Syrinx, your goal was to find the number of bricks on the invisible wall near Carole Chapel.  You had already found B1, B2, B3, and B4, and now your goal was to find B5.

On the Syrinx page, you were given that the average number of bricks on all 5 walls was 22. This information was enough to obtain B5.

Upon correctly entering this into the Syrinx room webpage, students were awarded the Crystal Key and taken to the Final Puzzle room.

Final Puzzle

The answers students obtained on the previous three rooms gave them coordinates to the three hidden walls that were missing.

MathDay2018PuzzleMap

This is how you can check your answers. Your answers should all contain only two digits, one even and one odd. Using the first digit as the x coordinate and the second digit as the y coordinate, remove the walls from the above map that are missing! This will help you get a path to the final maze.

The last step was to use a large table of pass phrases that would be used to whisper to the Gatekeeper who was guarding the final puzzle.

  • Using the intersection of the numbers found at Ben Franklin and the Vietnam Memorial would provide you with a specific color.
  • Using the intersection of the numbers found at Ben Franklin and the Carole Chapel provided you with a specific animal/pet.
  • Using the intersection of the numbers found at the Vietnam Memorial and Carole Chapel provided you with a specific sound.

This lead students to whisper “The Yellow Pot-Bellied Pig Rings a Bell” to the Gatekeeper, who let them enter the final puzzle pictured at the top of this post. Using the game piece that had action figures from the movie (Parzival, Art3mis, and Aech) along with a magnet on the bottom that held a metal ball underneath the surface, they had to traverse the life sized game board to the top right corner without letting the metal ball hit a hidden wall beneath and fall down.

If they solved all their problems correctly and used the correct path, they were then given an Easter Egg with candy and a password they entered into the final web page that would give them a time stamp on when they completed the race.

The top five teams were announced during an award ceremony.

The Process

Putting something together like this takes months of preparation, and a few late nights leading up to game day.  It is a fun and rewarding process putting such a scavenger hunt together and seeing the satisfaction on the faces of students as they solve the final puzzle and complete the scavenger hunt.

It is a lot of work, however, so I’m fine with the wait in between.

Dried Apricots

The Fall 2018 semester is less than 2 weeks away, and so what better time to talk to you about drying some Apricots. This is a very basic problem that I hope many of you can solve on your own. For those of you that cannot, I believe you will be able to understand the solution without too much difficulty.

The 133rd Riddle put out by The Riddler included the following Eternal question about percentages:

You loaded a drying shed containing 1,000 kilograms of apricots. They were 99 percent water. After a day in the shed, they are now 98 percent water. How much do the apricots weigh now?

First of all, you should try this problem on your own.  I think you can get it.  Before you do, however, at least get a guess.  That is the point of the problem, since even I was a little surprised by the answer.

The Solution

I’ll talk you through it first, so that you can perhaps follow how a mathematician would do it afterwards.

If 99% of 1000 kilograms is water, than 990 kilograms of the apricots is water, leaving 10 kilograms (1%) of what will eventually be the purely dried-out apricots. These are all the initial values prior to the apricots going in the shed.

Now, they are left in the shed for a day, and some of the water has evaporated out of the apricots. We need to understand that the total weight of the apricots and the weight of the water has both decreased by some amount (the water that evaporated).  We also need to understand that the 10 kilograms of dried apricots to-be has not changed.

If we are given that the apricots are now 98% water we want to deduce that the 10 kilograms of dried apricots to-be now represents 2% of the entire weight, rather than the original 1%.

So, 2% of what is equal to 10?  That can be quickly found by dividing 10 by .02, which gives you 500. The answer is 500 kg.

Wait, what? The weight decreased by half?  Did I do this right?

Indeed, we have, as you can check the answer seeing that both 500-10=490 and 0.98*500 = 490.

A mathematician would have given the unknown and desired quantity of the weight of apricots after a day some variable name, like w. Then, she would have set up the equation .02w=10, and solved for w by dividing both sides by .02.

Gambler’s Ruin: A Lesson in Probability

The Riddler Express for Friday, February 23 was a gambler’s ruin problem, so I thought I would walk you through the solution and show you how the following problem can be solved.

Suppose you have one quarter, and I have two quarters.  Each round, a die is rolled. If a 1, 2, 3, or 4 is rolled, you will win a quarter from me.  If a 5 or 6 is rolled, I will win a quarter from you.  The game is won when someone retrieves all 3 quarters.

What is the probability that you will win the game?

Breaking it down into cases

Let’s use W to represent you winning a round, and L can represent you losing a round.  We can see that you will win this game if you win the next two rounds and capture both my quarters: WW.

You could also win by first winning, then losing, and then winning twice in a row: WLWW.

You could also win along the path WLWLWW.  And WLWLWLWW.  And so on.

The probability of any given W is 2/3.  The probability of any given L is 1/3.  To find the probability of two wins in a row, we would need to multiply and get (2/3)(2/3)=(2/3)^2.

The probability of WLWW occurring is (2/3)(1/3)(2/3)(2/3)=(1/3)(2/3)^3.  Similarly, the probability of WLWLWW occurring is (1/3)^2(2/3)^4.  And so on.

So, we would need to calculate the difficult infinite sum

\displaystyle (2/3)^2+(1/3)(2/3)^3+(1/3)^2(2/3)^4+\ldots .

This is not too difficult for the savvy statistician/mathematician, but it seems like a headache for the rest.  There is an easier approach.

A Recursive Relationship

Let P_i represent the probability that you will eventually win this game if you are holding i quarters.

If you are not holding any quarters, then i=0 and P_0 =0 since you have a zero probability of winning (indeed, you have lost).

If you are holding all three quarters, then i=3 and P_3=1 since you have won the game (and therefore have a probability 1 of winning).

Since we are holding one quarter in this problem, i=1, and we want to find P_1.  Here is the weird trick.  We will solve for this by also solving for P_2, the probability that you will eventually win when holding 2 quarters.

We need to recognize the following two relationships:

  1. The probability that we will eventually win the game when we hold 1 quarter is the probability that we win the next round AND eventually win the game from holding 2 quarters. The equation that results from this logic is P_1 = (2/3)P_2.
  2. The probability that we will eventually win the game when we hold 2 quarters is the probability that we lose the next round AND eventually win the game from holding 1 quarter OR we simply win the next round.  The equation that results in this logic is P_2 = (1/3)P_1+2/3.

Now, we use some substitution. Using the equation from 1 inside the equation from 2, we get

\displaystyle P_2 = (1/3)(2/3)P_2+2/3.

Multiplying the constants together gives you P_2=2/9P_2+2/3. Subtracting 2/9P_2 from both sides gives you 7/9 P_2 = 2/3.  Finally, multiplying both sides by the 9/7 will give P_2 = (9/7)(2/3) = 6/7.

Now, using the original equation from 1 we get P_1 = (2/3)(6/7) = 4/7.

Gambler’s Ruin Equation: The General Result

To explain how to obtain the general result would be over most people’s heads, so I’ll simply give it to you.

Suppose on each individual round you have a probability p of winning and a probability q = 1-p of losing.

When you begin with a bank of i, and you are interested in reaching a fortune of N, then the probability that you will reach that fortune is given as

\displaystyle \frac{1-(q/p)^i}{1-(q/p)^N}.

To see how this applies to our problem, you will need to recognize that p=2/3, q=1/3, i=1, and N=3.

Notice that q/p = (1/3)/(2/3) = 1/2, so when we plug everything into that equation, we get

\displaystyle \frac{1-(1/2)^1}{1-(1/2)^3} = \frac{(1/2)}{1-(1/8)} = \frac{(1/2)}{(7/8)} = \frac12\cdot\frac87 = \frac47.

 

The Yanghui Triangle, Part II

Welcome back for round two!  If you missed Part I, you can catch up here.

An Alternative Explanation

In the first part of this post, we explored the following specific consequence of the triangle that we generalized:

\displaystyle \binom{6}{2} = \binom{5}{1}+\binom{5}{2}.

I recognized that I lacked an example of why this might be true from a counting perspective.  Using the triangle below, we see that the equation above is saying that 15=5+10.

YanghuiTriangle
Here is Yanghui’s Triangle for convenience.

So, why is this true from a counting perspective?

Let’s say we want to select 2 of these 6 letters: ABCDEF.  There should be 15 ways of doing this according to the triangle.  Let’s list them below.

AB, AC, AD, AE, AF, BC, BD, BE, BF, CD, CE, CF, DE, DF, ED

Now, let’s try it another way.  Let’s first make a decision on the F.  We can either select it, or not select it.  Let’s explore both cases.

We Select The F. Now, our task is to select 1 more of the 5 letters ABCDE.  We can do this in \binom{5}{1}=5 different ways.  We are left with AF, BF, CF, DF, and EF.

We Do Not Select F. Now, our task is to select 2 of the 5 letters ABCDE.  We can do this in \binom{5}{2} = 10 ways. Here they are: AB, AC, AD, AE, BC, BD, BE, CD, CE, DE.

Now, combine these two together for the total number of ways to select 2 of 6 letters.

OK, now onto some more fun properties.

Powers of 2

If we sum each row of Yanghui’s Triangle, you will notice a pattern.

  1. Sum of 0th row: 1
  2. Sum of 1st row: 2
  3. Sum of 2nd row: 4
  4. Sum of 3rd row: 8
  5. Sum of 4th row: 16

And so on.  From the title of this section, you probably have already guessed the pattern.  If we think of the first row as the zeroth row instead, then we simply take 2 to the power of the row to get the sum.

Why does this work? You may have to review the first post to recall that the numbers in each row can be used as the coefficients when expanding expressions such as (x+y)^6.  From the previous post,

\displaystyle (x+y)^6 = x^6+6x^5y+15x^4y^2+20x^3y^3+15x^2y^4+6xy^5+y^6.

Let’s use this result, and plug in 1 for both x and y. The left part of the equation says that this is just 2^6.  The right part of the equation says that this is the sum of the numbers in the 6th row of Yanghui’s Triangle.

Fibonacci Sequence

PascalsTriangleFibonacci
By using hexagons to construct the triangle, the lines that create Fibonacci are easy to construct

The picture above says it all.  By creating lines that run parallel to the top left side of the hexagons and summing up the numbers that it passes through, we get Fibonacci’s Sequence.

Why is this?

Let’s explore the line that goes through 1, 4, and 3, which sums to 8.  The 1, 4, and 3 correspond with the following counting principles: choosing 0 of 5 things, 1 of 4 things, and 2 of 3 things.  To see why this must sum up to the 5th Fibonacci number (again, thinking that the first 1 in Fibonacci’s sequence is the null, or zeroth number), review my explanations in Approach 1 and Approach 2 in Jumping Lily Pads. You can also watch the quick video there.

For a brief explanation of why \binom{5}{0}+\binom{4}{1}+\binom{3}{2} sums up to the fifth Fibonacci number, it is like counting the number of ways that a frog can jump from shore to the fifth lily pad if the frog can jump one or two lily pads at a time.

He can make 5 total jumps, 0 of which are skipping any lily pads: \binom{5}{0}=1.

He can make 4 total jumps, 1 of which must be a double: \binom{4}{1} = 4.

He can make 3 total jumps, 2 of which must be doubles: \binom{3}{2} = 3.

As was described in that post, this is equivalent to summing up the number of ways you can jump to lily pad 3 (3) and the number of ways you can jump to lily pad 4 (5).