Mathemagical Black Holes:

Number Play, Calculators, and Card Tricks

By Michael W. Ecker, Ph.D.

 

Dr. Michael W. Ecker, Editor

Recreational & Educational Computing (REC)

E-mail: DrMWEcker@aol.com

 

Associate Professor of Mathematics / Pennsylvania State University/ Wilkes-Barre Campus

Based on articles appearing in computer magazine columns in the 1980s and in REC (Part 1: 1986-1993)

Dedicated to Martin Gardner, REC Senior Mathematical Correspondent

 

Introduction

 

The legend of Sisyphus is a lesson in inevitability. No matter how Sisyphus tried, the small boulder he rolled up a hill would always come down at the last minute, pulled inexorably by gravity.

Like the legend, the physical universe has strange entities – black holes – that pull everything toward them, never to escape. But did you know that we have comparable bodies in recreational mathematics?

At first glance, these bodies may be more difficult to identify in the world of number play than their more famous brethren in physics. What could numbers such as 123, 153, 6174, 4, and 15 have in common with each other, as well as with various card tricks?

These are mathematical delights interesting in their own right, but much more so collectively because of the common theme linking them all. I call such individual instances mathemagical black holes.

 

The Sisyphus String: 123

 

Suppose we start with any natural number, regarded as a string, such as 9288759. Count the number of even digits, the number of odd digits, and the total number of digits. These are 3 (three evens), 4 (four odds), and 7 (total of seven digits). So, use these digits to form the next string or number, 347.

Now repeat with 347, counting evens, odds, total number, to get 1, 2, 3, so write down 123. If we repeat with 123, we get 123 again. The number 123 with respect to this process and universe of numbers is a mathemagical black hole. All numbers in this universe are drawn to 123 by this process, never to escape.

Will every number really be sent to 123? Try 122333444455555666666777777788888888999999999.

The numbers of evens, odds, and total are 20, 25, and 45, respectively. So, our next iterate is 202545, the number obtained from 20, 25, 45. Iterating for 202545 we find 4, 2, and 6 for evens, odds, total, so we have 426 now. One more iteration using 426 produces 303, and a final iteration from 303 produces 123.

At this point, any further iteration is futile in trying to get away from the black hole of 123, since 123 yields 123 again. If you wish, you can test a lot more numbers more quickly with a computer program in BASIC or other high-level programming language. Here's a fairly generic one (old Microsoft GWBasic):

 

Sample Program: The 123 Mathemagical Black Hole

 

1 CLS

2 PRINT "The 123 Mathemagical Black Hole / (c) 1993-1998, Dr. M. Ecker"

3 PRINT "Editor, Recreational & Educational Computing"

4 PRINT "909 Violet Terrace/ Clarks Summit, PA 18411 (USA)"

5 PRINT: PRINT "I'll ask you to input a positive whole number now."

6 PRINT "I'll count the numbers of even digits, odd digits, and total."

7 PRINT "From that I'll form the next number. Surprisingly, we always"

8 PRINT "wind up reaching the mathemagical black hole of 123...": PRINT

10 INPUT "What is your initial whole number"; N$: PRINT

20 IF VAL(N$)<1 OR VAL(N$)<>INT(VAL(N$)) THEN 10

30 FOR DIGIT=1 TO LEN(N$)

40 D$=MID$(N$,DIGIT,1)

50 IF D$=" " THEN 70

60 IF VAL(D$)/2 = INT(VAL(D$)/2) THEN EVEN=EVEN+1 ELSE ODD=ODD+1

70 NEXT DIGIT

80 PRINT "EVEN, ODD, TOTAL"

90 NU$=STR$(EVEN)+STR$(ODD)+STR$(EVEN+ODD)

100 PRINT EVEN; " "; ODD; " "; EVEN+ODD; " ---> New number is "; VAL(NU$)

110 PRINT: IF VAL(NU$)=VAL(N$) THEN PRINT "Done.": END

120 N$=NU$: EVEN=0: ODD=0: GOTO 30

 

Program Note: If you wish, modify line 110 to allow the program to start again. Or revise to automate the testing for all natural numbers in some interval. (Author's Update Note, 1998: Although it would be easy to replace GOTO and other crude structures with more accepted ones, the program will run in more recent Basics such as QBasic and QuickBasic, and perhaps even Visual Basic. Purists should feel free to tinker.)

 

What is a Mathemagical Black Hole?

 

There are two key features that make our example interesting:

1) Once you hit 123, you never get out, just as reaching a black hole of physics implies no escape.

2) Every element subject to the force of the black hole (the process applied to the chosen universe) is eventually pulled into it. In this case, sufficient iteration of the process applied to any starting number must eventually result in reaching 123.

Of course, once drawn in per 2), an element never escapes, as 1) ensures.

A mathemagical black hole is, loosely, any number to which other elements (usually numbers) are drawn by some stated process. Though the number itself is the star of the show, the real trick is in finding interesting processes.

 

Formalized Mathematical Definition

 

I define a mathemagical black hole as a triple (b, U, f), where U is a set, b is an element of U, and f: U ---> U is a function, all satisfying:

1') f(b) = b;

2') For each x in U, there exists a natural number k satisfying  f(f(f(...f(x)...))) = b   (k iterates of f).

 

Here, b plays the role of the black-hole element, and the iteration indicates k-fold (repeated) composition of functions.

For the Sisyphus String, b = 123, U = {natural numbers}, and  f(n) =  the number obtained by writing the concatenated string counting number of even digits of n, number of odd digits, and total number of digits.

Why does this example work, and why do most mathemagical black holes occur? My argument is to show that large inputs have smaller outputs, thus reducing an infinite universe to a manageable finite one. At that point, an argument by cases, or a computer check of the finitely many cases, suffices.

In the case of the 123 hole, we can argue as follows: If n > 999, then f(n) < n. In other words, the new number that counts the digits is smaller than the original number. (It's intuitively obvious, but try induction if you would like rigor.) Thus, starting at 1000 or above eventually pulls one down to under 1000. For n < 1000, I've personally checked the iterates of f(n) for n = 1 to 999 by computer programs such as the one above. The direct proof is actually faster and easier, as a three-digit string for a number must have one of these possibilities for (# even digits, # odd digits, total # digits):

(0,3,3) or (1,2,3) or (2,1,3) or (3,0,3)

So, if n < 1000, within one iteration, you must get one of these four triples. Now apply the rule to each of these four and you'll see that you always produce (1,2,3) – thus resulting in the claimed number of 123.

For generalized Sisyphian strings, see REC issue #48, released fall 1992, and other issues since then.

 

Words to Numbers: 4

 

Master recreationist Martin Gardner wrote me about this a decade ago. Take any whole number and write out its numeral in English, such as FIVE for the usual 5. Count the number of characters in the spelling. In this case, it is 4 – or FOUR. So, work now with 4 or FOUR. Repeat with 4 to get 4 again.

As another instance, try 163. To avoid ambiguity, I'll arbitrarily say that we will include spaces and hyphens in our count. Then, 163 appears as ONE HUNDRED SIXTY-THREE for a total count of 23. In turn, this gives 12, then 6, then 3, then 5, and finally 4.

Though this result is clearly language-dependent, other natural languages may have a comparable property, but not necessarily with 4 the black hole.

 

Narcissistic Numbers: 153

 

It is well known that, other than the trivial examples of 0 and 1, the only natural numbers that equal the sum of the cubes of their digits are 153, 370, 371, and 407. Of these, only 153 has a black-hole property.

To create a black hole, we need to define a universe (set U) and a process (function f). We start with any positive whole number that is a multiple of 3. Recall that there is a shortcut to test whether you have a multiple of 3. Just add up the digits and see whether that sum is a multiple of 3. For instance, 111111 (six ones) is a multiple of 3 because the sum of the digits, 6, is. However, 1111111 (seven ones) is not.

Since we are going to be doing some arithmetic, you may wish to take out a hand-calculator and/ or some paper. Write down your multiple of 3. One at a time, take the cube of each digit. Add up the cubes to form a new number. Now repeat the process. You must eventually reach 153. Moreover, once you reach 153, another iteration just gets you 153 again.

Let's test just one initial instance. Using the sum of the cubes of the digits, if we start with 432 – a multiple of 3 – we get 99, which leads to 1458, then 702, which yields 351, finally leading to 153, at which point, future iterations keep producing 153. Note also that this operation or process preserves divisibility by 3 in the successive numbers.

 

Sample Program: The 153 Mathemagical Black Hole

 

10 CLS

20 PRINT "The mathemagical black hole 153...": PRINT

30 PRINT "Simple test program for sum of cubes of digits...": PRINT

40 PRINT "Copyright 1993-1998, Dr. Michael W. Ecker"

50 PRINT "Editor, Recreational & Educational Computing"

60 PRINT "909 Violet Terrace, Clarks Summit, PA 18411 (USA)": REM old address

70 PRINT

80 INPUT "Number to be tested"; N: PRINT

90 IF N/3>INT(N/3) OR N<1 THEN PRINT "Positive multiples of 3 only!": GOTO 70

100 IF N>10000000# THEN PRINT "Let's stick to numbers under 10000000": GOTO 80

110 N$=STR$(N): L=LEN(N$): 'Convert to a string to manipulate digits

120 SUMCUBES=0: 'Initialize sum

130 FOR DIGIT = 1 TO L

140 V(DIGIT)=VAL(MID$(N$,DIGIT,1)): 'Get value of each digit

150 CU(DIGIT)=V(DIGIT)*V(DIGIT)*V(DIGIT): ' Cube each digit

160 SUMCUBES=SUMCUBES + CU(DIGIT): 'Keep running total of sum of cubes

170 NEXT DIGIT

180 PRINT "The sum of the cubes of the digits of " N " is " SUMCUBES

190 IF SUMCUBES=N THEN PRINT "Success! Found a black hole!": PRINT: GOTO 70

200 N=SUMCUBES: GOTO 110

 

Program Note: This older program version continues forever, so break out after you've grown weary.

 

One nice thing is that it is easy to edit this program to test for black holes using larger powers. (It is well known that none exists for the sum of the squares of the digits, as one gets cycles.)

In more formal language, we obtain the 153 mathemagical black hole by letting U = 3Z+ = {all positive integral multiples of 3} and   f(n) = the sum of the cubes of the digits of n. Then b = 153 is the unique black-hole element. (For a given universe, if a black hole exists, it is necessarily unique.)

Not incidentally, this particular result, without the "black hole" terminology or perspective, gets discovered and re-discovered annually, with a paper or problem proposal in one of the smaller math journals every few years. I even used this in one of my Recreational Computing columns in Popular Computing somewhere in the period 1983-85 and/or the Mathematical Recreations column I founded in Byte (1984-85) prior to my founding REC Jan. 1986.

The argument for why it works is similar to the case with the 123 example. First of all, 13 + 33 + 53 = 153, so 153 is indeed a fixed point. Second, for the black-hole attraction, note that, for large numbers n,   f(n) < n. Then, for suitably small numbers, by cases or computer check, each value eventually is "pulled" into the black hole of 153. I'll omit the proof.

To find an analogous black hole for larger powers (yes, there are some), you will need first to discover a number that equals the sum of the fourth (or higher) powers of its digits, and then test to see whether other numbers are drawn to it. This is a recurring activity in REC.

 

Card Tricks, Even

 

Here's an example that sounds a bit different, yet which meets the two criteria for a black hole. It's a classical card trick. It admits of interesting extensions, but we'll stick to the original version here.

Remove 21 cards from an ordinary deck. Arrange them in seven horizontal rows and three vertical columns. Ask somebody to think of one of the cards without telling you which card.

Now ask him which of the three columns contains the card. Regroup the cards by picking up the cards by whole columns intact, but being sure to sandwich the column that contains the chosen card between the other two columns. Now re-lay out the cards by laying out by rows (i.e., laying out three across at a time). Repeat asking which column, regrouping cards with the designated column being in the middle, and re-dealing out by rows. Then repeat one last time.

At the end, the card chosen must be in the center of the array, which is to say, card #11. This is the card in the fourth row and second column.

There are at least two ways to prove this, but the easier way is to draw a diagram that illustrates where a chosen card will end up next time. But for those who enjoy programs, try this one from one of my readers:

 

Sample Program: The 21-Cards Mathemagical Black Hole

 

10 CLS: PRINT "The 21 Cards - Program adapted by Dr. M. Ecker for REC

100 DEFINT A-Z: DIM V(21), X(7,3)

120 ITER=0

130 FOR N=1 TO 21: V(N)=N: NEXT N

140 PRINT: PRINT "Pick a card, please...": PRINT

150 IF ITER=3 THEN PRINT: PRINT "Your card is "; V(11): END

160 ITER=ITER+1

170 N=0

180 FOR I=1 TO 7: FOR J=1 TO 3

190 N=N+1

200 X(I,J)=V(N)

210 NEXT J: NEXT I

220 PRINT: PRINT

221 FOR I=1 TO 7

222 PRINT USING "## "; X(I,1); X(I,2); X(I,3)

223 NEXT I

230 PRINT

240 INPUT "Column of card (1, 2, or 3)"; C

250 IF C<1 OR C>3 THEN 240

260 FOR K=1 TO 3: O(K)=K: NEXT K

270 IF C<>2 THEN SWAP O(C), O(2)

290 N=0

300 FOR K=1 TO 3: FOR I=1 TO 7

310 J=O(K)

320 N=N+1

330 V(N)=X(I,J)

340 NEXT I: NEXT K

350 GOTO 150

 

This trick, as with the Sisyphian strings, generalizes somewhat. See REC #48 again for more on this.

 

Kaprekar's Constant: What a Difference 6174 Makes!

 

Most black holes, nonetheless, involve numbers. Take any four-digit number except an integral multiple of 1111. (I.e., don't take one of the nine numbers with four identical digits.) Rearrange the digits of your number to form the largest and smallest strings possible. That is, write down the largest permutation of the number, the smallest permutation (padding initial zeros as digits, if needed, to create a four-digit number), and subtract. Apply this same process to the difference just obtained. Within a total of seven steps, you always reach 6174. At that point, further iteration with 6174 is pointless: 7641 – 1467 = 6174.

Example: Start with 8028. The largest permutation is 8820, the smallest is 0288, and the difference is 8532. Repeat with 8532 to calculate 8532 - 2358 = 6174. Your own example may take more steps, but you will reach 6174.

 Play with this old-fashioned GWBASIC program if you have BASIC (and if not, contact me!):

10 ' ** MBH, for Dr. M. Ecker, REC **

20 CLS : PRINT TAB(23); "THE MATHEMAGICAL BLACK HOLE, 6174"

30 PRINT TAB(32); "(Sept. 4, 1987)"

40 PRINT : PRINT TAB(27); "Enter a four-digit number"

50 PRINT TAB(23); "Except 1111 or a multiple thereof."

60 PRINT

80 L = 1: K = 0: X1 = 2: Y1 = 10

90 INPUT N: IF N / 1111 = INT(N / 1111) THEN 40

100 IF N < 1000 OR N > 9998 THEN 90

110 A$ = STR$(N)

120 F1$ = MID$(A$, 2, 1): V(1) = VAL(F1$)

130 F2$ = MID$(A$, 3, 1): V(2) = VAL(F2$)

140 F3$ = MID$(A$, 4, 1): V(3) = VAL(F3$)

150 F4$ = MID$(A$, 5, 1): V(4) = VAL(F4$)

190 '

200 ' ** SORT **

210 SW = 0

220 FOR I = 1 TO 3

230 X = V(I): Y = V(I + 1)

240 IF X >= Y THEN 270

250 SWAP V(I), V(I + 1): SW = 1

270 NEXT I

280 IF SW = 1 THEN 210

290 '

300 C$ = STR$(V(1)) + STR$(V(2)) + STR$(V(3)) + STR$(V(4))

310 D = VAL(C$)

320 LOCATE Y1 + 2, X1: PRINT D

330 E$ = STR$(V(4)) + STR$(V(3)) + STR$(V(2)) + STR$(V(1))

340 G = VAL(E$)

350 LOCATE Y1 + 3, X1: PRINT "-";

360 PRINT USING "####"; G

380 LOCATE Y1 + 4, X1: PRINT "_______"

390 LOCATE Y1 + 5, X1: PRINT D - G

400 H = D - G

410 IF H = 6174 THEN K = K + 1

420 IF K = 2 THEN 520

430 A$ = STR$(H)

440 '

460 L = L + 1

470 X1 = X1 + 10

480 IF X1 > 74 THEN X1 = 2: Y1 = 16

490 LOCATE Y1 - 2, X1: PRINT "LOOP "; L

500 LOCATE Y1, X1: PRINT A$

510 GOTO 120

520 PRINT : PRINT "That concludes program..."

530 INPUT "Run again (Y or N)"; run$

540 IF run$ = "Y" OR run$ = "y" THEN RUN ELSE END

 

The Divisive Number 15

 

Take any natural number larger than 1 and write down its divisors, including 1 and the number itself. Now take the sum of the digits of these divisors. Iterate until a number repeats.

The black-hole number this time is 15. Its divisors are 1, 3, 5, and 15, and these digits sum to 15. This one is a bit more tedious, but it is also that much more strange at the same time.

 

Fibonacci Numbers: Classical Results as Black Holes

 

Many an endearing problem has charmed mathophiles with the Fibonacci numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... The first two numbers are each 1 and successive terms are obtained by adding the immediately preceding two elements. More formally, F(1) = 1 = F(2), and  F(n) = F(n-1) + F(n-2) for integers n > 2. (Technically, we usually start with subscript 0, but that won't be necessary here.)

One of the classical results is that the ratio of consecutive terms has a limiting value. That is, form the ratios F(n+1) / F(n): 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, etc. The ratios seem to be converging to a number around 1.6 or so. In fact, it is well known that the sequence converges to , known as the golden number, f (phi). Its value is roughly 1.618....

Had we used the ratios F(n) / F(n+1) instead, we would have obtained the reciprocal of f as the limit, but fewer authors use that approach.

I have some nice Basic programs for this and more general sequences. To get a quick feel for why f arises without using a program, assume that the numbers F(n+1)/F(n) approach a limit – call it L – as n increases. Divide both sides of the equation F(n) = F(n-1) + F(n-2) by F(n-1). For large n this equation is approximately the same as  L = 1 + 1/L. If we multiply both sides now by L and get all terms on one side, we obtain the quadratic equation . (*)

Solving by the quadratic formula yields two solutions, one of which is f . More about the second solution in a moment.

Notice that the above plausibility argument did not use the initial values  F(1) = 1 = F(2). Indeed, more generally, take any additive sequence – any sequence in which the third term and beyond are each obtained by adding the preceding two. Then, one gets the same result: convergence to f. The first two numbers need not even be whole numbers or positive. This is fun and easy to test in a program that you can write yourself.

Thus, if we extend the definition of black hole to require only that the iterates get closer and closer to one number, we have a black hole once again. (We can formalize this by replacing the two conditions of the definition by a single limit requirement. I'll omit this here.)

But there is still another black hole one can derive from this. Consider the function  f(x) = 1 + 1/x for nonzero real numbers x. I selected – or rather, stumbled across – this function f because of the simple argument above that gave f as a limit. Start with a seed number x and iterate function values  f(x)f(f(x)), etc. One obtains convergence to f – but still no appearance of the second number that is the solution to the quadratic equation (*) above.

Is there a connection between the two solutions of (*)?

First, each number is the negative reciprocal of the other. Each is also one minus the other. Second, had we formed the ratios F(n) / F(n+1), we would have obtained the absolute value of the second solution instead of the first solution.

Third, note that our last function ff(x) = 1 + 1/x, could not use an input of 0 because division by zero is undefined. However, this in turn rules out any x for which  f(x) = 0, because then  f(f(x)) is undefined. The solution to the equation  f(x) = 1 + 1/x = 0 is just x = –1. Thus, x may not equal –1, either.

We have not finished. We must now avoid  f(x) = -1 (otherwise,  f(f(x)) = 0 and then  f(f(f(x))) is undefined). Solving f(x) = 1 + 1/x = -1 gives x = –1/2. If we continue now working backwards with function f's pre-images we find, in succession, that we must similarly rule out –2/3, then –3/5, –5/8, –8/13, etc. Notice that these fractions are precisely the negatives of the ratios of consecutive Fibonacci numbers in the reverse order than we considered. All of these must be eliminated from the universe for f, along with 0. The limiting ratio, the second golden ratio, must also be eliminated from the universe.

In closing out this brief connection of Fibonacci numbers to the topic, I would be remiss if I did not follow my own advice on getting black holes by looking for fixed points: values x such that  f(x) = x. For f(x) = 1 + 1/x, we obtain our two golden numbers. As things are set up, the number  f = 1.618... is an attractor with the black-hole property, while –1/f = –0.618... is a repeller. All real inputs except zero, the numbers  -F(n-1) / F(n), and this second golden number (–1/f ) lead to the attractor, our black hole f.

 

Classical Unsolved Problems as Black Holes

 

Even classical unsolved problems sometimes fall into this black-hole scenario. Consider the Collatz Conjecture, dating back to the 1930s and still an open question (though sometimes also identified with the names of Hailstone, Ulam, and Syracuse). Start with a natural number. If odd, triple and add one. If even, take half. Keep iterating. Must you always reach 1?

If you start with 5, you get 16, then 8, then 4, then 2, then 1. Success! In fact, this problem has the paradoxical property that, though one of the hardest to settle definitively, is among the easiest to program (a few lines).

If you do reach 1 – and nobody has either proved you must, nor shown any example that doesn't – then you next get 4, then 2, then 1 again, a cycle that repeats ad infinitum. Hmm... a cycle of length three. We're interested now only in black holes, which really are cycles of length one. So, let's be creative and fix this up by modifying the problem.

Define the process instead by taking the starting number and breaking it down completely into factors that are odd and even. For instance, 84 is 2x2x3x7. Pick the largest odd factor. In the example that would be 3x7=21. (Just multiply all the odd prime factors together. The only non-odd prime is 2.) Now triple the largest odd factor and then add 1. This answer is the next iterate.

Now try some examples. You should find that you keep getting 4. Once you hit 4, you stay at 4, because the largest odd factor in 4 is 1, and 3 x 1 + 1 = 4. Anybody who proves the Collatz Conjecture will prove that my variation is a mathemagical black hole as well, and conversely.

Because this is so easy to program, I will omit a program here.

 

Close

 

Other examples of mathemagical black holes arise in the study of stochastic processes. Under certain conditions, iteration of matrix powers draws one to a result that represents long-term stability independent of an input vector. There is a striking resemblance to convergence results in such disciplines as differential equations, too.

Some are amazingly creative and even silly. For instance, one we had just a few years ago involved counting the number of dashes used to create a digit in the Diode font – that's the font in which each digit appears as on an LCD screen or calculator. Again, we found iteration always leading to one number.

Quite apart from any utility, however, the teasers and problems here are intriguing in their own right. However, the real value for me is in seeing the black-hole idea as the unifying theme of seemingly disparate recreations. This is an ongoing pursuit in my newsletter, Recreational & Educational Computing, in which we've had additional ones. I invite readers to send me other examples or to correspond using address on first page or by E-mail:

DrMWEcker@aol.com

Web Page for REC Info and Free Game: http://members.aol.com/DrMWEcker/REC.html