cp's OEIS Frontend

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.

A351850 a(n) is the number of iterations of the computation of the A351849 tag system when started from the word encoding n, or -1 if the number of iterations is infinite.

This page as a plain text file.
%I A351850 #21 Apr 10 2022 15:33:34
%S A351850 0,2,24,6,20,30,128,14,152,30,120,42,64,142,300,30,108,170,236,50,84,
%T A351850 142,284,66,300,90,40656,170,216,330,40524,62,384,142,260,206,264,274,
%U A351850 996,90,40628,126,596,186,256,330,40492,114,388,350,520,142,224,40710
%N A351850 a(n) is the number of iterations of the computation of the A351849 tag system when started from the word encoding n, or -1 if the number of iterations is infinite.
%C A351850 If x is even, the A351849 tag system evolves from the word encoding x to the word encoding x/2 in x iterations; if x is odd, x+1 iterations are required to produce the word encoding (3x+1)/2.
%C A351850 See A351849 for additional comments, links and examples.
%H A351850 Paolo Xausa, <a href="/A351850/b351850.txt">Table of n, a(n) for n = 1..10000</a>
%H A351850 Liesbeth De Mol, <a href="https://doi.org/10.1016/j.tcs.2007.10.020">Tag systems and Collatz-like functions</a>, Theoretical Computer Science, Volume 390, Issue 1, 2008, pp. 92-101.
%H A351850 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>.
%F A351850 a(n) = (Sum_{k=0..A006666(n)} 2*floor((A070168(n,k)+1)/2)) - 2.
%e A351850 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.
%t A351850 (* First program, based on the tag system definition *)
%t A351850 t[s_]:=StringDrop[s,2]<>StringReplace[StringTake[s,1],{"1"->"23","2"->"1","3"->"111"}];
%t A351850 nterms=100;Table[Length[NestWhileList[t,StringRepeat["1",n],#!="1"&]]-1,{n,nterms}]
%t A351850 (* Second program, more efficient, based on formula *)
%t A351850 c[x_]:=If[OddQ[x],(3x+1)/2,x/2];
%t A351850 nterms=100;Table[Total[Map[If[OddQ[#],#+1,#]&,NestWhileList[c,n,#>1&]]]-2,{n,nterms}]
%o A351850 (Python)
%o A351850 def A351850(n):
%o A351850     s, steps = "1" * n, 0
%o A351850     while s != "1":
%o A351850         if s[0] == "1": s += "23"
%o A351850         elif s[0] == "2": s += "1"
%o A351850         else: s += "111"
%o A351850         s = s[2:]
%o A351850         steps += 1
%o A351850     return steps
%o A351850 nterms = 100
%o A351850 print([A351850(n) for n in range(1, nterms + 1)])
%Y A351850 Cf. A006666, A070168, A285098, A351849.
%K A351850 nonn
%O A351850 1,2
%A A351850 _Paolo Xausa_, Feb 22 2022