%I #45 Sep 27 2021 21:01:50
%S 1,5,21,7,29,117,39,13,53,213,71,285,95,381,127,509,2037,679,2717,
%T 10869,3623,14493,4831,19325,77301,25767,8589,2863,11453,45813,15271,
%U 61085,244341,81447,27149,108597,36199,144797,579189,193063,772253,3089013,1029671,4118685
%N a(1) = 1; if a(n) is not divisible by 3, a(n+1) = 4*a(n) + 1, otherwise a(n+1) = a(n)/3.
%H Tristan Young, <a href="/A346035/b346035.txt">Table of n, a(n) for n = 1..15000</a>
%H Tristan Young, <a href="/A346035/a346035_1.c.txt">C code to generate a b-file for the first 15000 terms of this sequence</a>
%t a[1] = 1; a[n_] := a[n] = If[Divisible[a[n-1],3], a[n-1]/3, 4*a[n-1]+1]; Array[a, 50] (* _Amiram Eldar_, Jul 12 2021 *)
%o (Processing)
%o // generates all the numbers in the sequence before it first surpasses 1 billion
%o int n;
%o void setup() {
%o n = 1;
%o noLoop();
%o }
%o void draw() {
%o print(n + ",");
%o while (true) {
%o if (n % 3 == 0) {
%o n /= 3;
%o } else {
%o n *= 4; n++;
%o }
%o print(n);
%o if (n == 1 || n >= 600000000) {
%o break;
%o } else {
%o print(", ");
%o }
%o }
%o }
%o (PARI) a(n) = if (n==1, 1, my(x=a(n-1)); if (x % 3, 4*x+1, x/3)); \\ _Michel Marcus_, Aug 12 2021
%Y Cf. A006370, A128333, A153727.
%K easy,nonn
%O 1,2
%A _Tristan Young_, Jul 02 2021