A275545 Number of new duplicate terms at a given iteration of the Collatz (or 3x+1) map starting with 0.
0, 0, 0, 0, 1, 1, 2, 4, 8, 16, 34, 67, 137, 272, 540, 1061, 2074, 4022, 7763, 14914, 28556, 54499, 103729, 196945, 373201, 705964, 1333413, 2515298, 4739834, 8926089
Offset: 0
Examples
a(3) = 0 since all the members of x_3 are distinct. a(4) = 1 since in x_4 the number 1 appears twice (there is 1 duplicate).
Links
- Wikipedia, Collatz conjecture
Crossrefs
Cf. A275544.
Programs
-
Mathematica
nmax = 25; s = {0}; b[0] = 1; Do[s = Join[3 s + 1, s/2]; Print[n]; b[n] = s // Union // Length, {n, 1, nmax}]; a[n_] := If[n == 0, 0, 2 b[n - 1] - b[n]]; a /@ Range[0, nmax] (* Jean-François Alcover, Nov 16 2019 *)
-
PARI
first(n)=my(v=vector(n),u=[0],t); for(i=1,n, t=2*#u; u=Set(concat(vector(#u,j,3*u[j]+1),u/2)); v[i]=t-#u); concat(0, v) \\ Charles R Greathouse IV, Aug 05 2016
-
Python
x = [0] n = 20 for i in range(n): x_tmp = [] for s in x: x_tmp.append(3*s+1) x_tmp.append(s*0.5) x = x_tmp length_tmp = len(x) x = list(set(x)) print(length_tmp-len(x))
Comments