Ivars Peterson's MathTrek

February 2, 1998

# Digits, Squares, and Cycles

Fascinating patterns lurk among the digits of whole numbers.

Pick a positive integer, such as 57. Square each of the digits, then add the squares together: 5^2 + 7^2 = 25 + 49 = 74. Do the same thing with the digits of 74: 7^2 + 4^2 = 49 + 16 = 65. Keep repeating the procedure, using successive sums of squares.

You end up with the following sequence of numbers: 57, 74, 65, 61, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, and so on. Notice that after a few steps, the numbers begin repeating themselves in a definite cycle (or loop): 37, 58, 89, 145, 42, 20, 4, and 16.

Try another number, say 88. The following sequence arises: 88, 128, 69, 117, 51, 26, 40, 16, 37, 58, 89, 145, 42, 20, 4, 16, 37, 58, 89, 145, 42, and so on. It takes a little longer to get there and the cycle's entry point (16) is different, but the same repeating set of numbers comes up.

Amazingly, it turns out that for a given positive integer, this procedure always leads to one of just two cycles: either the cycle of numbers noted above or a string of 1s. For instance, starting with 19 produces the sequence 82, 68, 100, 1, 1, 1, and so on. Beginning with 123,457 leads to the repeating set of numbers 4, 16, 37, 58, 89, 145, 42, and 20.

Mathematician Eugene D. Nichols, now retired from Florida State University in Tallahassee, first encountered a mathematical proof establishing this cyclic digital behavior in a Polish book of problems by Hugo Steinhaus, published in 1958. However, Steinhaus proved the theorem only for squaring the digits. "I got curious about what would happen when you did it to the third power, fourth power, and so on," Nichols says.

For example, suppose you use 3 as the exponent and start with the positive integer 57. You get 5^3 + 7^3 = 125 + 343 = 468. Continuing the procedure generates the following numbers: 792 (4^3 + 6^3 + 8^3), 1080, 513, 153, 153, 153, 153, and so on. In general, this procedure always leads to some sort of cycle, and there are nine possible cycles. The longest cycles contain only three numbers: 55, 250, and 133; 160, 217, and 352; and 160, 217, and 352.

"We wanted to find out whether there is any relationship between the number of loops we get and the power to which the digits are raised," Nichols says. Collecting data up to the fifteenth power, "we couldn't discern any kind of relationship, except one. For the odd powers, there are more loops than for the even powers."

Jerry Glynn of MathWare in Urbana, Ill., and Theodore Gray of Wolfram Research devote a chapter of their book The Beginner's Guide to Mathematica Version 3 to the problem and suggest ways of calculating the necessary sequences and searching for patterns.

Glynn had learned about the problem from Nichols during a lull at a mathematics meeting in San Diego last year. "He started me off on the problem with a conspiratorial tone and a gleam in his eye," Glynn says. "He also started very, very slowly so I followed the steps easily until I could move ahead on my own. I was trapped and no longer bored."

In the Beginner's Guide, Gray notes, "Readers should be made aware that Jerry is having some sort of religious experience. He seems awed by these numbers. It is quite remarkable that the cycle lengths are so short, given how large the numbers are."

There's still lots to explore in this niche of number theory, and there's no proper proof yet that all numbers and all exponents always cycle. Glynn and Gray invite people to keep them informed of any progress by E-mail to info@mathware.com.