A277367 a(n) = gcd(A006666(n), A006667(n)) where A006666 and A006667 are respectively the number of halving and tripling steps in the '3x+1' problem.
0, 1, 1, 2, 1, 2, 1, 3, 1, 1, 2, 1, 1, 1, 1, 4, 3, 2, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 5, 2, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 4, 4, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 10, 10, 1, 1, 3, 3
Offset: 1
Keywords
Examples
a(17) = 3 because gcd(A006666(17), A006667(17)) = gcd(9, 3) = 3.
Programs
-
Maple
nn:=100: for n from 1 to nn do: m:=n:it0:=0:it1:=0: for j from 1 to 1000 while(m<>1) do: if irem(m,2)=0 then m:=m/2:it0:=it0+1: else m:=3*m+1:it1:=it1+1: fi: od: q:=gcd(it0,it1):printf(`%d, `,q): od:
-
Mathematica
Table[GCD[Count[NestWhileList[If[OddQ@ #, 3 # + 1, #/2] &, n, # > 1 &], ?EvenQ], Count[Differences[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, n, # > 1 &]], ?Positive]], {n, 87}] (* Michael De Vlieger, Oct 13 2016, after Harvey P. Dale at A006666 and A006667 *)
-
PARI
a(n) = {my(se = 0); my(so = 0); while (n!=1, if (n % 2, so++; n = 3*n+1, se++; n = n/2);); gcd(se, so);} \\ Michel Marcus, Oct 13 2016
Formula
a(2^m) = m.