This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A300997 #43 Nov 11 2019 00:50:55 %S A300997 0,1,3,4,6,8,10,11,13,15,17,19,21,23,24,26,28,30,32,34,36,38,40,41,43, %T A300997 45,47,49,51,53,55,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,87, %U A300997 89,91,93,95,97,99,101,103,105,107,109,111,113,114,116,118,120,122,124,126,128 %N A300997 a(n) is the number of steps needed to reach a stable configuration in the 1D cellular automaton initialized with one cell with mass n and based on the rule "each cell gives half of its mass, rounded down, to its right neighbor". %C A300997 The cellular automaton is initialized with 1 cell with mass n. The evolution rule consists of each cell keeping half of its mass, rounded up (ceiling(mass / 2)), and giving half of its mass, rounded down (floor(mass / 2)), to its right neighbor. a(n) is the number of steps needed to reach the stable configuration made of n cells with mass 1. %C A300997 Observations/conjectures: it appears that the finite difference of this sequence only contains 1's and 2's, that the runs of 2's are delimited by isolated 1's and tend to become larger and larger. One can probably write a(n) = 2*n - Sum_{k=1..n} I(k) where I(n) is the indicator function of some other sequence. See A305992. %H A300997 Wikipedia, <a href="https://en.wikipedia.org/wiki/Cellular_automaton">Cellular automaton</a> %H A300997 Wikipedia, <a href="https://en.wikipedia.org/wiki/Floor_and_ceiling_functions">Floor and ceiling functions</a> %e A300997 Diagram illustrating a(5) = 6: %e A300997 0 [ 5 ] <-- initial configuration %e A300997 | \ %e A300997 3 2 %e A300997 | \ %e A300997 1 [ 3 ][ 2 ] %e A300997 | \ | \ %e A300997 2 1 1 1 %e A300997 | \| \ %e A300997 2 [ 2 ][ 2 ][ 1 ] %e A300997 | \ | \ | %e A300997 1 1 1 1 1 %e A300997 | \| \| %e A300997 3 [ 1 ][ 2 ][ 2 ] %e A300997 | | \ | \ %e A300997 1 1 1 1 1 %e A300997 | | \| \ %e A300997 4 [ 1 ][ 1 ][ 2 ][ 1 ] %e A300997 | | | \ | %e A300997 1 1 1 1 1 %e A300997 | | | \| %e A300997 5 [ 1 ][ 1 ][ 1 ][ 2 ] %e A300997 | | | | \ %e A300997 1 1 1 1 1 %e A300997 | | | | \ %e A300997 6 [ 1 ][ 1 ][ 1 ][ 1 ][ 1 ] <-- stable %e A300997 | | | | | %e A300997 1 1 1 1 1 %e A300997 | | | | | %e A300997 7 [ 1 ][ 1 ][ 1 ][ 1 ][ 1 ] %e A300997 | | | | | %e A300997 ... ... ... ... ... %o A300997 (C) %o A300997 #include <stdio.h> %o A300997 #include <string.h> %o A300997 #define N 100 %o A300997 void e(int *t, int *s) { %o A300997 int T[N], i = 0; memset(T, 0, sizeof(T)); %o A300997 while (i < *s) { %o A300997 int f = t[i] / 2; %o A300997 T[i] += f + (t[i] % 2); %o A300997 T[++ i] += f; %o A300997 } %o A300997 if (T[*s] != 0) { *s += 1; } %o A300997 for (i = 0; i < *s; i ++) { t[i] = T[i]; } %o A300997 } %o A300997 int a(int n) { %o A300997 int t[N], s = 1, i = 0; t[0] = n; %o A300997 while (s != n) { i ++; e(t, &s); } %o A300997 return i; %o A300997 } %o A300997 int main() { int n; for (n = 1; n <= N; n ++) { printf("%d, ", a(n)); } printf("\n"); } %o A300997 (PARI) do(v) = {keep = vector(#v, k, ceil(v[k]/2)); move = vector(#v, k, floor(v[k]/2)); nv = vector(#v+1, k, if (k<=#v, keep[k], 0) + if (k==1, 0, move[k-1])); if (nv[#nv]==0, nv = vector(#nv-1, k, nv[k])); nv;} %o A300997 a(n) = {vs = [n]; vend = vector(n, k, 1); nb = 0; while(vs != vend, vs = do(vs); nb++); nb;} \\ _Michel Marcus_, Jul 02 2018 %o A300997 (PARI) a(n) = {my(v=[n], res=0); while(Set(v)!=[1], res++; v = concat([ceil(v[1] / 2), vector(#v-1, i, v[i]\2 + ceil(v[i+1]/2)), vector(v[#v] > 1, k, v[#v] \ 2)])); res} \\ _David A. Corneth_, Jul 03 2018 %Y A300997 Cf. A305992, A088803. %K A300997 nonn %O A300997 1,3 %A A300997 _Luc Rousseau_, Jun 14 2018