My son was born last September. While he doesn’t hate sleep as much as his sister did, he still needs a bit of help to drop off.

I’m not at all musically inclined, and I seem unable to remember more than a couple of lines from wordy songs (my version of “Papa’s gonna buy you a mockingbird” rapidly veers into nonsense as I try to think of a rhyme for the next line), so when the girl was little I hit upon the strategy of singing counting songs to lull her off to sleep.

At first, I went through the standards: “one man went to mow”, “ten green bottles on the wall”, and so on. The first problem I encountered is that when you start singing a counting-backwards song, you have to pick a number to start at.

The second problem is that they’re really, really boring, and it’s the baby I want to go to sleep, not me.

One day my wife the primary teacher taught me a song she uses at school:

Let’s count back in ones from 10,

Cock-a-doodle-doodle-doo,

10, 9, 8 and 7,

Cock-a-doodle-doodle-doo.

6, 5, 4 and 3,

Cock-a-doodle-doodle-doo,

2 and 1 and don’t forget the zero,

Cock-a-doodle-doodle-doo!

It’s another counting backwards song, but the great thing about it is that once you’re finished, you start again counting back in twos, then threes, and so on for as long as you need until the baby is asleep.

Let’s count back in \(N\)s from \(10N\),

Cock-a-doodle-doodle-doo,

\(10N\), \(9N\), \(8N\), \(7N\), …

My record for the girl is “let’s count back in twenty-twos”. I did say she doesn’t like going to sleep.

Eventually, I got bored of that too, so I started counting back in different sequences: squares, triangular numbers, fibonacci numbers, primes, binary, ternary.

Let’s count back in fibonacci numbers from 89,

Cock-a-doodle-doodle-doo,

89, 55, 34, 21,

Cock-a-doodle-doodle-doo.

13, 8, 5 and 3,

Cock-a-doodle-doodle-doo,

2 and 1 and don’t forget the other 1,

Cock-a-doodle-doodle-doo!

These didn’t quite work: if I take a while to work out the next number it disrupts the rhythm of the song. It’s also very easy to make an off-by-one error: while the normal song starts at \(10N\), you sing 11 numbers including the zero (which you mustn’t forget!)

So I wanted a counting-forwards song that had a bit of complexity to it, but not too much.

A few months ago, while pushing the boy around the block, I came up with a nice rule for an integer sequence:

For each \(N\), repeatedly subtract the largest power of 2 dividing \(N\) until you get to 0 (but don’t include the zero!)

It goes like this:

1

2

3, 2

4

5, 4

6, 4

7, 6, 4

8

9, 8

…

This works beautifully! It’s open-ended, so I can keep going if he takes a while to drop off, but the rule is just hard enough to keep my brain occupied without making me break the rhythm.

He’s normally asleep by the time I get to 64, but sometimes I keep going just for fun.

Last night he had a horrible time with teeth coming through, so he was ready for his first nap at 6am! I recorded myself singing the lullaby sequence as I pushed him around the block:

Of course, as a fan of the Online Encyclopedia of Integer Sequences, I checked if it was already in. It wasn’t! So I submitted it, and it’s now entry A343934.