Oh, when the ants come marching in

(No, that’s not a typo, I did not forget the “s” and the “i,” this post will be about ants)

Occasionally I go swimming. The problem is that I always lose count of how many laps I’ve done. It takes slightly too long to just remember what number the previous lap is – because my mind starts wandering. So I came up with a strategy: singing counting songs. Like “the ants go marching.”
You know:

The ants go marching one by one, hurrah, hurrah
The ants go marching one by one, hurrah, hurrah
The ants go marching one by one,
The last one stops to have some fun*
And they all go marching down to the ground
To get out of the rain…

gif of an ant dancing
This ant just stopped to have some fun.

One verse takes me about the same time to swim a lap, so it’s perfect. And because of the combination of the number and the rhyme, I don’t really forget what number I was on.
The song goes on with increasing numbers:

The ants go marching two by two, hurrah, hurrah
The last one stops to go to the loo…

The ants go marching three by three, hurrah, hurrah
The last one stops to have a wee…

The ants go marching four by four, hurrah, hurrah
The last one stops to slam the door…


However, a few weeks ago when I was happily swimming and internally singing, my mind started wandering anyway. I was wondering about the math of the song. How many ants would we need to have to make it work? And apparently, thinking about math and swimming also makes me lose count of laps.

Obviously, I did not find the answer during my swim session. But I have now. Here is the problem:

  • There is a row of ants marching down to the ground. Initially, the ants are marching in single file, then double, then three by three etc. until – let’s say – ten by ten.
  • There is always a random lonely single ant at the end of the parade who gets distracted by something, stops, and basically gets lost to the colony.
  • I want to figure out how many ants do you start with to make this song work.

The answer lies in the lowest common multiple (LCM). That’s a name given to the lowest number that is the multiple of two or more numbers. For example, the LCM of 4 and 6 is 12. Add 7 to the list and the LCM is 84. In other words, it is the lowest number you can find that can be divided by all your given numbers.

In the case of ants marching, at the end of the song, we’ll have lost as many ants as verses we’ve song. So if we sing it 10 times, there will have been 10 ants stopping to do some random action (that poor ant in verse seven though, she went to heaven), which is a lucky break because we are already looking for a number that needs to be divisible by 10 (and that number minus 10, can still be divided by 1). In other words: the answer to this conundrum lies in finding the LCM of all the numbers 1 through 10.**

Even more luck for me: there are several websites that calculate this for you (though there are some tricks to help you solve it). It turns out that the LCM of numbers 1 through 10 is 2520. In other words: there need to be 2520 ants in our initial parade to make my version of the song work. (If anyone feels the sudden urge to write a simulation to illustrates this song, please let me know; I know it could look cool.)

In case you are curious, going up to 11 requires 27720 ants, same for 12 verses, and for 20 verses we’d need to start out with a whopping 232792560 ants. The rule is that to end up with ants marching by n, you need the LCM(1,….,n).

However, considering that in the case of black garden ants, the average colony size is 4000-7000, marching up to 10 by 10 is pretty much the limit.
The most practical application of LCMs has nothing to do with ants, which are usually considered a pest even though all they really want is to clean up that crummy mess you left. No, the application has to do with solving fractions or word problems involving fractions. For example, if you share a cake with some friends, say I eat a quarter, my friend V isn’t very hungry so she eats a sixth, and my other friend S didn’t finish his dinner so is super hungry and he eats a third, you could use the LCM to figure out the denominator and calculate how much of the cake is left:

We ate 1/4 + 1/6 + 1/3
Using the LCM of 4, 6 and 3 this is 3/12 + 2/12 + 4/12
In other words, we ate: 9/12 or 3/4
So there is still 1/4 cake left.

Not for long though, I’ll probably eat it later.

Arfcher meme: Do you want ants? Because that's how you get ants.
Clean up after yourself when eating cake.


* I know I have the lyrics wrong here and it’s the little one that stops to tie its shoe but that doesn’t help with the math that I will get into later. Also, lyrics vary: while I sing have some fun, the internet tells me it’s “sucks his thumb”. Later on in the song, I definitely get more creative with the rhymes. Well, I say that got creative, but it was more likely a joint effort of a nation of six-year-olds.

** I really need to thank my friends (V&S) because I utterly confused myself by trying to find a “rule” and they basically solved my problem for me. #NerdFriends

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.