Work

The Look-and-Say Sequence: Terms in Output-Linear Time and Digits in O(n) Steps

Year: 2026
Type: preprint
Abstract: Let a(n) be the n-th term of the look-and-say sequence (A005150), a(1)=1, a(n+1)=D(a(n)), where D writes the length of every run of equal digits followed by the digit, and let |a(n)| ~ 1.567 * lambda^n be its number of digits, lambda=1.3036 (A005341). Every term is a concatenation of strings from a set A of 99 strings, the 92 Conway elements and 7 transient words, and A is generated by a cut test and verified by a finite closure check that proves a(t+1) is the product of x over w_t for the word w_t = sigma^t(1). This gives three exact algorithms: the whole term a(n) in |a(n)|(1+o(1)) bytes of memory copy plus O(lambda^(n/2)) other operations, which is optimal because the output has that size; any digit or block of a(n) in O(n) steps on big integers, without building the term; and the length |a(n)| and the numbers of digits 1,2,3 in a(n) from linear recurrences of order at most 79 (order 72 for the length), proved by a finite residual check. All claims are proved. In Python, a(68) with 105,745,224 digits takes 0.05 s, 48 times less than stepwise expansion over Conway elements; |a(10^5)| takes 0.99 s and |a(10^6)| takes 36.9 s; a digit of a(3000) at position 10^300 is read in 0.96 ms. The OEIS table of A005150 stops at n=25.
Author: Kim, Mark
Language: English
Open Access status: green
OpenAlex ID: W7225749629
Cites:
Cited by:
Related to: