Happy 10*9*8+7+6-5+4*321 !
10*9*8+7+6-5+4*321Happy New Year!
— Museum of Math (@MoMath1) January 3, 2012
A quick check with Mathematica verified that, yes indeed, 10*9*8+7+6-5+4*321 = 2012. Wow! How in the world did anyone discover that rare factoid? And how long will it be until another year arrives that can be similarly expressed?
That’s the sort of question that’s so easy to answer with Mathematica that I couldn’t not have a look. It turns out that what seemed to me like a rare jewel is as common as dirt. In fact, there is only one year in the next 100 that can’t be expressed by interspersing +, -, *, /, or nothing between the numbers in order from 10 to 1! In subsequent correspondence with George Hart, the museum’s Chief of Content, he told me that he learned the idea from Hans Havermann, who wrote about it in a blog post last year. I’ve discovered what he had up his sleeve: abundant computing.
Let’s call an expression like the one above, with the numbers 10, 9, …, 1 interspersed with operators, a 10-expression. To check what years could be formulated as 10-expressions, I strung together the component characters into character strings and then told Mathematica to interpret those as mathematical expressions. Since there are 5 different operators and 9 operator positions between the 10 numbers, there are 59 = 1953125 different calculations to make. With brutish force, I generated every one of them and had a look at the result.
This is how it works. Here are the numbers:
And the operators:
The set of all 1953125 possible combinations of the 5 operators in 9 positions is given by:
opTuples is a list, each element of which is a list of 9 operators. For example:
I interspersed each such tuple among the 10 numbers using Mathematica‘s Riffle function, which effectively shuffles two lists together, and applied StringJoin to concatenate that into a single string that expresses an arithmetic calculation:
Applying ToExpression to that string evaluates the corresponding mathematical expression and returns the value it represents:
I encapsulated those operations in the function ShowNExpressions that calculates all the possibilities, selects those in a given range of dates, and nicely formats the result. Imagine my surprise when I applied it to the next 100 years, and it appeared that every one of them was expressible as a 10-expression, and most of them in more than one way (on closer examination I saw that one year, 2102, was missing). Here’s the beginning of that list:
It turns out that if you have enough numbers in the sequence, you can express any year with some combination of operators. Ten numbers is just about the sweet spot. With 9-expressions, you get only 79% of the next 100 years. With 10-expressions you get 99%. 11-expressions go way overboard, giving an average of 51 different ways to express each year.
There’s nothing special about the sequence 10, 9, …, 1. The sequence 1, 2, …, 9 works, too (in 6 different ways):
My colleague Ed Pegg explored this variation when he was playing with a draft of this post. He sent the last of those expressions to National Public Radio Puzzlemaster Will Shortz, who used it as the January 29 Sunday Puzzle (sorry, the deadline for solutions has passed!).
Other number sequences work as well. You can express 2012 using the first 9 digits of π (2 ways):
And the first 9 Fibonacci numbers (3 ways):
My telephone number works, and it’s likely that yours does, too, if it doesn’t contain too many zeros.
I found another pleasant surprise in the operator patterns of different expressions for the same year. Take, for example, 2040.
The first three expressions for that year have the same “+654*3+2+1” suffix, which means that their prefixes all express the same number. But there’s a curious pattern there, where multiplication marches right, gobbling up minuses and depositing pluses in its wake. Is it a fluke, or is there something general going on?
I calculated that pattern for 10-expressions and saw that regardless of the position of the multiplication, you do indeed get the same number:
That, of course, doesn’t show that it always works that way, but we can ask Mathematica to prove the general case. This expression gives the value expressed by the sequential integers m to n with multiplication in position p. The simplified result does not contain p, which shows that the value does not depend on the position of the multiplication, regardless of the number sequence.
In an age when natural resources are growing ever more scarce, computing resources are growing ever more abundant. The extravagantly wasteful computation above—calculating nearly two million numbers in order to filter out the few hundred I was interested in—took 48 seconds on my laptop. It would have taken many weeks on the university mainframe computer when I was an undergraduate. The very fact that I could be extravagant—and didn’t have to spend any time trying to be clever or efficient—meant that I could explore and discover new things. Hans Havermann knew this already: it’s abundant computing that makes these rare jewels as common as dirt.