Fast evaluation of the look-and-say sequence: lengths, digit counts and digits

The look-and-say sequence is defined by a(1) = 1 and a(n+1) = D(a(n)), where D replaces every maximal block of equal digits by its length followed by the digit. The word a(n) has length of order 1.3036^n, so it can be written down only for small n. We give algorithms for two problems whose answers are small: the length and the digit counts of a(n), and the digit of a(n) at a prescribed position. Conway's decomposition of a(n) into 99 atoms yields a 99 x 99 nonnegative integer matrix. We prove that the length of a(n) and the numbers of digits 1, 2, 3 in a(n) become, after a shift by 7 and the removal of explicit additive constants, solutions of one linear recurrence of order 71 whose characteristic polynomial is irreducible. All four numbers are therefore read off one residue x^{n-8} mod c(x), which is computed by a left-to-right chain of Kronecker squarings; the last squaring is replaced by a bilinear form. The cost is O(M(rn) + r^2 n) bit operations with r = 71. For the digit at a position we describe a block algorithm that replaces the table of lengths, which occupies about 19 n^2 bits, by checkpoints of x^e mod c and fixed-precision arithmetic for the decisions inside blocks; every answer is certified by an exact computation. In Python on one core, |a(n)| for n = 3 * 10^6, a number with 345,411 decimal digits, is computed in 7.1 seconds, and digits of a(3 * 10^5) are extracted within 370 MB of memory.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-12-03
DOI
https://doi.org/10.5281/zenodo.24783042
Primary Topic
Mathematical and Computational Methods
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Fast evaluation of the look-and-say sequence: lengths, digit counts and digits

Mark Kim
Zenodo (CERN European Organization for Nuclear Research)
Mathematical and Computational Methods
preprint

Fast evaluation of the look-and-say sequence: lengths, digit counts and digits

Mark Kim
preprint en

Abstract

The look-and-say sequence is defined by a(1) = 1 and a(n+1) = D(a(n)), where D replaces every maximal block of equal digits by its length followed by the digit. The word a(n) has length of order 1.3036^n, so it can be written down only for small n. We give algorithms for two problems whose answers are small: the length and the digit counts of a(n), and the digit of a(n) at a prescribed position. Conway's decomposition of a(n) into 99 atoms yields a 99 x 99 nonnegative integer matrix. We prove that the length of a(n) and the numbers of digits 1, 2, 3 in a(n) become, after a shift by 7 and the removal of explicit additive constants, solutions of one linear recurrence of order 71 whose characteristic polynomial is irreducible. All four numbers are therefore read off one residue x^{n-8} mod c(x), which is computed by a left-to-right chain of Kronecker squarings; the last squaring is replaced by a bilinear form. The cost is O(M(rn) + r^2 n) bit operations with r = 71. For the digit at a position we describe a block algorithm that replaces the table of lengths, which occupies about 19 n^2 bits, by checkpoints of x^e mod c and fixed-precision arithmetic for the decisions inside blocks; every answer is certified by an exact computation. In Python on one core, |a(n)| for n = 3 * 10^6, a number with 345,411 decimal digits, is computed in 7.1 seconds, and digits of a(3 * 10^5) are extracted within 370 MB of memory.

Zenodo (CERN European Organization for Nuclear Research)
Mathematical and Computational Methods
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon