login
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.
1

%I #11 Nov 05 2016 08:06:32

%S 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,

%T 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,

%U 1,1,1,2,1,2,1,2,2,1,1,1,2,10,10,1,1,3,3

%N 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.

%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>

%F a(2^m) = m.

%e a(17) = 3 because gcd(A006666(17), A006667(17)) = gcd(9, 3) = 3.

%p nn:=100:

%p for n from 1 to nn do:

%p m:=n:it0:=0:it1:=0:

%p for j from 1 to 1000 while(m<>1) do:

%p if irem(m,2)=0

%p then

%p m:=m/2:it0:=it0+1:

%p else

%p m:=3*m+1:it1:=it1+1:

%p fi:

%p od:

%p q:=gcd(it0,it1):printf(`%d, `,q):

%p od:

%t 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 *)

%o (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

%Y Cf. A006666, A006667, A277068.

%K nonn

%O 1,4

%A _Michel Lagneau_, Oct 11 2016