1

11

21

1211

111221

...


Do you get it?
#!/usr/bin/perl
@NewNum=[1];
for (1) {
  @Num = @NewNum;
  @NewNum = [];
  print (@Num,"\n");
  for ($count = 0; $count++; $count < (@Num)) {
    $CurrentDigit = $Num[$count];
    $NextDigit = $Num[$count+1];
    if ($CurrentDigit = 1) {
      if ($NextDigit = 1) {
        @NewNum = [@NewNum,2,1]
        $count++;
      } else {
        @NewNum = [@NewNum,1,1]
      }
    } else {
      @NewNum = [@NewNum,1,2] 
    }
  }
}
1 => 11
11 => 21
21 => 1211
1211 => 111221
111221 => 2111121211
2111121211 => 12212112111221

Prolly not right, but it fits the starting list. In English... A 1 not followed by a 1 gets lonely, so it calls over another 1 to be next to it. A 1 followed by a 1 is happy, too much so, and it turns into a 2. The 1 immediately following the new 2 is too stunned to do anything. A 2 wishes it could be a 1 again, and it puts a 1 in front of itself. Every number gets one reaction, either calling over another number, changing, or being stunned, in order from left to right.
This is known as the Look and Say Sequence and was pioneered by and related to much mathematics done by Conway. nieken's got it right in describing it, and the next few terms would be:

1
11
21
1211
111221
312211
13112221
1113213211
31131211131221
13211311123113112211
11131221133112132113212221
3113112221232112111312211312113211
. . .

If we had started the sequence with another digit 'd' (instead of 1) where 2 =< d =< 9, then the sequence would have read:

d
1d
111d
311d
13211d
111312211d
. . .

An interesting and related problem is that of how many digits are in then nth term in the sequence. After counting, we notice that it is:

1
2
2
4
6
6
8
10
14
. . .

This sequence is asymptotic to C*lamda^n where lamda is Conway's Constant (approx equal to 1.30357...) and is given by the unique positive real root of the (behemoth) equation:

0 = x^71 - x^69 - 2x^68 - x^67 + 2x^66 + 2x^65 + x^64 - x^63 - x^62 - x^61 - x^60 - x^59 
    + 2x^58 + 5x^57 + 3x^56 - 2x^55 - 10x^54 - 3x^53 - 2x^52 + 6x^51 + 6x^50 + x^49 
    + 9x^48 - 3x^47 - 7x^46 - 8x^45 - 8x^44 + 10x^43 + 6x^42 + 8x^41 - 4x^40 - 12x^39
    + 7x^38 - 7x^37 + 7x^36 + x^35 - 3x^34 + 10x^33 + x^32 - 6x^31 - 2x^30 - 0x^29 - 3x^28
    + 2x^27 + 9x^26 - 3x^25 + 14x^24 - 8x^23 - 7x^21 + 9x^20 - 3x^19 - 4x^18 - 10x^17 
    - 7x^16 + 12x^15 + 7x^14 + 2x^13 - 12x^12 - 4x^11 - 2x^10 - 5x^9 + x^7 - 7x^6 + 7x^5
    - 4x^4 + 12x^3- 6x^2+ 3x - 6

Log in or register to write something here or to contact authors.