Order of Operations
I’m apparently several years late to the party on this one, but I just saw the following tweet:
A maths meme that is actually funny rather than stupid:
— KJ Cheetham ❄️🔶 (@kj_cheetham) July 13, 2019
Solve carefully!
230 - 220 x 0.5 =
You probably won’t believe it but the answer is 5!#maths
At first glance, this is of course false. Order of operations dictates that \(230 - 220 \times 0.5 = 230 - 110 = 120\). But, as a reply to the tweet makes clear, we’ve fallen right into kj_cheetham’s trap. He’s using \(5!\) to mean \(5\) factorial, which is exactly \(120\) – so the answer is indeed 5!
This started me wondering whether we could find other such numbers \((a, b, c, n)\) such that \(a - \frac{b}{c} = n\) and \(\frac{a-b}{c}=n!\). (I’m reading “multiply by \(0.5\)” as “divide by \(2\)” here, since it’s always nicer to work with integers.) Since these are just two equations in four unknowns – three if we fix \(n\) – there are infinitely many solutions, possibly even infinitely many integer solutions. Many of those solutions, though, are going to involve very large numbers, and so they won’t look very snappy on Twitter.
With that in mind, let’s restrict ourselves to the case where \(a, b, c, d > 1\) and \(c \leq n+1\). That last one might seem a little arbitrary, but it’s a way to make sure that the numbers don’t balloon in size, and we’ll see later that it’s actually a very helpful way to phrase that constraint.
We’re looking for solutions to the following two equations:
-
\(a-\frac{b}{c}=n!\)
-
\(\frac{a}{c}-\frac{b}{c}=\frac{a-b}{c}=n\)
Note that \(\frac{b}{c}\) is an integer by equation 1, and so \(\frac{a}{c}\) must be as well by equation 2. Now, if we eliminate \(b\), we wind up with \(\frac{a}{c}(c-1)=n((n-1)!-1)\). Since \(\frac{a}{c}\) is an integer, \(c-1\) must be a factor of \(n((n-1)!-1)\).
Since every number less than \(n\) divides into \((n-1)!\), and hence doesn’t divide into \((n-1)!-1\), \(c-1\) must be a factor of \(n\). If, further, we want a formula that will work for any \(n\), we must in particular consider the case of \(n\) prime, giving us only two possibilities: \(c=2\) or \(c=n+1\).
After this it’s just a matter of solving the two simultaneous equations. The \(c=2\) case gives us \(a=2n!-2n\) and \(b=2n!-4n\), while \(c=n+1\) gives \(a=(n+1)(n-1)!-(n+1)\) and \(b=(n+1)(n-1)!-(n+1)^2\).
(The first of these formulae was found by @jameslockharts as well, but my derivation is, as far as I can tell, nowhere on the original Twitter thread.)
I wrote a computer program to list these for small \(n\). Here’s what it came up with for \(c=2\):
- 40 - 32 / 2 = 4!
- 230 - 220 / 2 = 5!
- 1428 - 1416 / 2 = 6!
- 10066 - 10052 / 2 = 7!
- 80624 - 80608 / 2 = 8!
- 725742 - 725724 / 2 = 9!
- 7257580 - 7257560 / 2 = 10!
- 79833578 - 79833556 / 2 = 11!
- 958003176 - 958003152 / 2 = 12!
And here are the results for \(c=n+1\):
- 25 - 5 / 5 = 4!
- 138 - 108 / 6 = 5!
- 833 - 791 / 7 = 6!
- 5752 - 5696 / 8 = 7!
- 45351 - 45279 / 9 = 8!
- 403190 - 403100 / 10 = 9!
- 3991669 - 3991559 / 11 = 10!
- 43545588 - 43545456 / 12 = 11!
- 518918387 - 518918231 / 13 = 12!
The numbers do get pretty big pretty fast, but, combined with the small values of \(c\), I think that might actually make the results more impressive?