# The Barcode Sequence

The broad remit of the UK Mathematics Trust (www.ukmt.org.uk) is ‘to advance the education of children and young people in mathematics’. The main thrust of its activities involves the organisation of mathematical competitions of various kinds together with the selection and training of the British team for the annual International Mathematical Olympiad (IMO). The IMA supports the UKMT’s Mathematical Olympiad activities through its Education Grants.

On 2 December 2016, students sat the Senior Kangaroo paper which ‘allows students in the UK to test themselves on questions set for the best school-aged mathematicians from across Europe and beyond’ (from the rubric). Question 20 caught the eye of the author (see https://www.ukmt.org.uk/pdfs/SK16AllPages.pdf).

A barcode of the type shown in the two examples is composed of alternate strips of black and white, where the leftmost and rightmost strips are always black. Each strip (of either colour) has a width of 1 or 2. The total width of the barcode is 12. The barcodes are always read from left to right. How many distinct barcodes are possible?

This was one of 20 questions on the 1-hour long paper and the best of the students might well have found the recurrence formula \eqref{eq:1} below.

Suppose represents the number of barcodes of width . A recurrence relation is readily derivable. The black ends can be of three types:

1. Each of width 2 (1 case).
2. One of width 2 and the other of width 1 (2 cases).
3. Each of width 1 (1 case).

In case (a), for example, if we strip away the two (black) bars at the ends then we have barcodes of width 4 less than the original except that these are embraced by two white strips. Simply imagine, now, swapping black with white and white with black. Taking into account (a), (b) and (c), we have

(1)

If we take , , then , , . Table 1 shows the initial values of the ‘standard’ Fibonacci and barcode sequences. That there is a relationship between and is obvious.

There is a model for generating Fibonacci numbers. Consider any positive integer created by adding ones and twos where order is relevant. If represents the number of ways of doing this then , since can be divided into two sets, those ending in a 1 and the others ending in a 2. Clearly , . (The model omits the first 1 from the standard sequence. To accommodate this see the adjustment in Table 1.) We now derive an explicit formula for .

The auxiliary equation for (1) is , so . Hence or . The first has solutions and , where these represent the complex cube roots of unity. The second has solutions and where is the golden mean. So we have

For ,

(2)

For ,

(3)

For ,

(4)

For ,

(5)

and adding (3), (4) and (5,

We leave the somewhat tedious algebra to tease out and to the reader. We arrive at

Now

and

These give

More manipulation gives

The last term takes the values , 0, in a 3-cycle beginning with . These observations are confirmed by looking at Table 1.

Now

This is Binet’s formula derivable from the auxiliary equation .

Clearly

From this we can deduce the near Fibonacci sequence for , namely

(6)

Finally (6) can be established by mathematical induction. Start with two cases of (6) for , and combine with (1).

#### Graham Hoare CMath FIMA

##### Image credit: Barcode by Nico Kaiser / Flickr / CC BY-NC 2.0

Reproduced from Mathematics Today, February 2018