A346035 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.
1, 5, 21, 7, 29, 117, 39, 13, 53, 213, 71, 285, 95, 381, 127, 509, 2037, 679, 2717, 10869, 3623, 14493, 4831, 19325, 77301, 25767, 8589, 2863, 11453, 45813, 15271, 61085, 244341, 81447, 27149, 108597, 36199, 144797, 579189, 193063, 772253, 3089013, 1029671, 4118685
Offset: 1
Links
- Tristan Young, Table of n, a(n) for n = 1..15000
- Tristan Young, C code to generate a b-file for the first 15000 terms of this sequence
Programs
-
Mathematica
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 *)
-
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
-
Processing
// generates all the numbers in the sequence before it first surpasses 1 billion int n; void setup() { n = 1; noLoop(); } void draw() { print(n + ","); while (true) { if (n % 3 == 0) { n /= 3; } else { n *= 4; n++; } print(n); if (n == 1 || n >= 600000000) { break; } else { print(", "); } } }