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.

A340672 Number of repeated applications of the '4x+-1' operation needed to reach 1 from n, or -1 if 1 is never reached.

This page as a plain text file.
%I A340672 #36 Mar 14 2025 08:57:54
%S A340672 0,3,1,8,6,4,4,11,2,36,9,9,34,16,7,7,32,5,14,5,5,39,30,12,12,12,3,46,
%T A340672 37,37,28,19,10,10,10,10,44,35,35,26,26,17,17,17,8,8,8,8,42,33,33,33,
%U A340672 24,6,24,15,15,15,15,6,6,49,6,40,40,40,31,31,31,31,22
%N A340672 Number of repeated applications of the '4x+-1' operation needed to reach 1 from n, or -1 if 1 is never reached.
%C A340672 Start with any positive number n. Define f(n) as 'if n mod 3 = 1, f(n) = 4n-1; if n mod 3 = 2, f(n) = 4n+1; if n is divisible by 3, f(n) = n/3'. Apply this procedure repeatedly to reach 1. This sequence gives the number of steps required to reach 1, or -1 if 1 is never reached. The procedure is a modification of the famous Collatz procedure.
%C A340672 We can make a conjecture similar to that of Collatz to claim that the process will always reach 1. However, this is not proven yet.
%C A340672 It seems that more than 65 percent of the terms in this sequence satisfy a(i) = a(i+1). For example, 6655 of the first 10000 terms satisfy this condition.
%H A340672 Md. Towhidul Islam, <a href="/A340672/b340672.txt">Table of n, a(n) for n = 1..10001</a>
%F A340672 a(n) = 1+a(b(n)) for n>=2 where b(n) = 0, 3, 9, 1, 15, 21, 2, 27,... for n>=0 = 2* b(n-3)-b(n-6). - _R. J. Mathar_, Mar 14 2025
%e A340672 a(5)=6 because the trajectory of 5 is (5,21,7,27,9,3,1). That needs 6 repeated applications of the procedure to reach 1.
%p A340672 a:= proc(n) option remember; `if`(n=1, 0, 1 + (r->
%p A340672       a(`if`(r=0, q, 4*n+2*r-3)))(irem(n, 3, 'q')))
%p A340672     end:
%p A340672 seq(a(n), n=1..75);  # _Alois P. Heinz_, Jan 20 2021
%t A340672 a[n_] := a[n] = If[n == 1, 0, {q, r} = QuotientRemainder[n, 3]; 1 +
%t A340672      a[If[r == 0, q, 4n + 2r - 3]]];
%t A340672 Table[a[n], {n, 1, 75}] (* _Jean-François Alcover_, May 29 2022, after _Alois P. Heinz_ *)
%o A340672 (PARI) f(n) = my(m=n%3); if (m==1, 4*n-1, if (m==2, 4*n+1, n/3));
%o A340672 a(n) = my(s=n, c=0); while(s>1, s=f(s); c++); c; \\ _Michel Marcus_, Jan 18 2021
%Y A340672 Cf. A006577.
%K A340672 nonn,easy,look
%O A340672 1,2
%A A340672 _Md. Towhidul Islam_, Jan 15 2021