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.

 

Aliquot Divisors

When the idea came to write about this post, I had never came across the term “aliquot” to my recollection.  Let’s quickly deconstruct that sentence and assign some probabilities.

  • I’ve never came across the term “aliquot”: probability = 0.01
  • I don’t recall having come across the term “aliquot”: probability = 0.99

From this, I hope you’ve come to understand a few important things.

  • Probabilities must sum to 1
  • All probabilities must be non-negative and less than (or equal to) 1
  • I most likely don’t have a great short term memory.
  • I am most likely a pretty funny dude.

Sum of Divisors Function

After searching the term “Sum of Divisors function” a page with a wiki on the Online Encyclopedia of Integer Sequences came up.  On this, they define a function for the sum of the divisors for a number.

Let’s do a quick example before introducing notation and look at the number 40 (that’s how old I am for another month and a half).  What numbers divide 40 evenly?  That is, if you push 40, and then \div, what numbers can you push next so that the result is an integer (not a decimal).

Here are the divisors of 40: 1, 2, 4, 5, 8, 10, 20, 40.  A function that computes the sum of the divisors of a number should give an output of 1+2+4+5+8+10+20+40 = 90 whenever you input the value 40.

Now for the notation.  The sum of the divisors function is given as \sigma(n).  To apply the above example, this means that \sigma(40)=90. In other words, you input the value 40 into the sum of divisors function \sigma(\cdot), and the output is 90.

Let’s try a few others. What if we input 10?  That is, what is the value of \sigma(10)?

First, let’s find the divisors of 10: 1, 2, 5, 10. Next (and finally), sum them together: 1+2+5+10 = 18.  Thus, \sigma(10) = 18.

How about \sigma(11)?  The only divisors of 11 are 1 and 11 (which, as a side note, means that 11 is a prime number).  This means \sigma(11)=12.  If you inspect this example thoroughly, you should be able to deduce that the sum of the divisors of any prime number will be one more than the number.

Since 5 is a prime number, \sigma(5)= 6 (the sum of 1 and 5).  Likewise, since 7 is a prime number, \sigma(7)=8.

Now, try a few on your own.  Find \sigma(15) and \sigma(24).  The answers are below, but you can also check them by typing “sigma(15)” or “sigma(24)” into WolframAlpha. Technically, the correct code is DivisorSigma[1,15] and DivisorSigma[1,24], but you need not concern yourself with that.

So What are Aliquot Divisors?

The aliquot divisors of a number are what I have always known to be proper divisors of a number, which are all the divisors except the number itself.

So, the aliquot divisors of 40 are 1, 2, 4, 5, 8, 10, and 20 (we leave off 40).  And the sum of the aliquot divisors function is denoted by s(\cdot).  For our example, then, s(40)=1+2+4+5+8+10+20 =50.

With this sum of aliquot divisor function, s(n), we can now explore some fascinating things about different numbers.

Prime Numbers

For every prime number (a number only divisible by 1 and itself), the only aliquot divisor is 1.  So, by plugging any prime number into the function s(\cdot), the result will be 1.

Deficient Numbers

The numbers 4 and 10 are deficient numbers. Why? When you plug them into the sum of aliquot divisors function, s(\cdot), you will get a value smaller than the number.

The aliquot divisors of 4 are 1 and 2.  So, s(4)=3.  The aliquot divisors of 10 are 1, 2, and 5. So, s(10) = 8. Notice that each of the output values are smaller than the input values.  That means the numbers are deficient. 

Let’s recall what you learned about prime numbers in the previous section.  If p is a prime number, than s(p)=1.  From this we can deduce that all prime numbers are deficient.

Furthermore, since we have the above stated examples of 4 and 10 as deficient numbers, and we know they are not prime since they are divisible by something other than themselves and 1, then we can also deduce that not all deficient numbers are prime.

Abundant Numbers

The numbers 12 and 40 are abundant numbers? Why? When you plug them into the sum of aliquot divisors function, s(\cdot), you will get a value larger than the number.

We have already seen that s(40)=50. The aliquot divisors of 12 are 1, 2, 3, 4, and 6.  Thus, s(12) = 1+2+3+4+6=16.  Each output value is larger than the input value. That means the numbers are abundant. 

Perfect Numbers

The numbers 6 and 28 are perfect numbers? Why? When you plug them into the sum of aliquot divisors function s(\cdot), you will get the same value!

The aliquot divisors of 6 are 1, 2 and 3.  Thus s(6)=1+2+3=6.  The aliquot divisors of 28 are 1, 2, 4, 7, and 14.  Thus, s(28) = 1+2+4+7+14 = 28.  Each output value is the same as the input value!  That means the number is perfect.

Amicable Chains

Recently, I was introduced to the concept of amicable chains.  What if we continue to apply the sum of aliquot divisor function s(\cdot) over and over again?  For example, let’s try it with 12.  As we saw in the Abundant Numbers section, s(12)=16.

Now, what if we plug in 16?  Aliquot divisors of 16: 1, 2, 4, and 8.  Thus, s(16)=15.

Again? What if we plug in 15? Aliquot divisors of 15?  1, 3, and 5.  Thus, s(15)=9.

Again? Aliquot divisors of 9? 1 and 3.  Thus s(9)=4. The aliquot divisors of 4 are 1 and 2, so s(4)=3.  Since 3 is prime s(3)=1 and now we’re trapped at 1 forever.

This created the sequence

\displaystyle 12\rightarrow 16\rightarrow 15\rightarrow 9\rightarrow 4\rightarrow 3\rightarrow 1

If you do a lot of exploration, a lot of numbers will produce a sequence that ends at 1 and becomes trapped. Some don’t. Take the perfect numbers 6 and 28 for example.

Since s(6)=6, then 6 has a chain of length 1 since it goes directly back to itself.  So does 28.

There are other numbers that do weirder things.  Take 220 and 284 for example (you will definitely need to use WolframAlpha on these if you want to check. However, you’ll need to type in “sigma(220)-220” and “sigma(284)-284”.)  The sum of the aliquot divisors of 220 is 284, and the sum of the aliquot divisors of 284 is 220.  This produces a chain of length 2. There are several chains like this one.

With the aid of a computer program, I’ve found one of length 5 and another of length 28.  Using a similar program, I also stumbled upon interesting numbers like 1230 and 1248.  Although they do not produce chains, they take a while to get back to 1.  Using a very cool trick of emailing a former colleague with a higher level of number theory understanding, he was able to find out that it takes 185 terms to get back to 1 starting at 1230 and 1076 terms to get back to 1 if you start at 1248.

The interesting thing about these sequences are how really, really, big they get.


Answers to Above Posed Questions

\sigma(15) = 24, and \sigma(24) = 60.