Look-And-Say Sequence


According to John Conway, this sequence was constructed and presented to him by one of his students. The construction is rather random, it involves reading the number left to right, and write down the number of consecutive numbers.


e.g. for the number “1211”, reading left to right, there are “one ‘1’, one ‘2’ and two ‘1’”, so the next  number is “111221”. Reading this number again, we get “three ‘1’, two ‘2’ and one ‘1’”. Hence the next number is 312211.


Here is a Mathematica code of how to construct and list such sequence:




f[seed_] :=
Module[{a = seed},
s = Split[IntegerDigits[a]];
t = Map[Length, s];
u = Map[DeleteDuplicates, s] // Flatten;
v = Riffle[t, u];


For[i = 1, i <= n, i++,
Subscript[a, 1] = 1;
Subscript[a, i + 1] = f[Subscript[a, i]];

table = Table[Subscript[a, i], {i, 1, n}]





One of the curious property of this sequence, is that, if we allow L_n to denote the number of digits in the n-th Look-And-Say number, then the ratio \frac{L_n+1}{L_{n}} tends to an number (Conway proved that this is an algebraic number, being a root of a polynomial): http://en.wikipedia.org/wiki/Look-and-say_sequence







leng = IntegerLength[table]
Ratios[leng] // N


We see that the ratios tends towards the constant 1.303577269….



This piece code are so short, thanks for the many easy to use functions in Mathematica, such as IntegerDigits, FormDigits and Riffle.






Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s