OFFSET
1,2
COMMENTS
LINKS
Paolo Xausa, Table of n, a(n) for n = 1..10000
Liesbeth De Mol, Tag systems and Collatz-like functions, Theoretical Computer Science, Volume 390, Issue 1, 2008, pp. 92-101.
EXAMPLE
When started from 1111 (the word encoding the number 4), the system evolves as 1111 -> 1123 -> 2323 -> 231 -> 11 -> 23 -> 1, reaching the word 1 after 6 steps. a(4) is therefore 6.
MATHEMATICA
(* First program, based on the tag system definition *)
t[s_]:=StringDrop[s, 2]<>StringReplace[StringTake[s, 1], {"1"->"23", "2"->"1", "3"->"111"}];
nterms=100; Table[Length[NestWhileList[t, StringRepeat["1", n], #!="1"&]]-1, {n, nterms}]
(* Second program, more efficient, based on formula *)
c[x_]:=If[OddQ[x], (3x+1)/2, x/2];
nterms=100; Table[Total[Map[If[OddQ[#], #+1, #]&, NestWhileList[c, n, #>1&]]]-2, {n, nterms}]
PROG
CROSSREFS
KEYWORD
nonn
AUTHOR
Paolo Xausa, Feb 22 2022
STATUS
approved