%I #12 Sep 12 2017 21:31:47
%S 1,10,9,30,65,5,74,86,368,135,970,50,95,101,1045,178,793,7,214,196,18,
%T 423,133,200,2572,629,621,358,700,451,3167,1924,3611,1926,662,510,
%U 6688,437,1525,5072,3724,3161,1034,240,5848,2487,704,442,19120,1230,5138,3524
%N Smallest number k such that gcd(s1, s2) = n, where s1 is the sum of the odd numbers and s2 is the sum of the even numbers in the Collatz (3x+1) trajectory of k.
%e a(6) = 5 because the Collatz trajectory of 5 is 5 -> 16 -> 8 -> 4 -> 2 -> 1 with s1 = 5+1 = 6 and s2 = 16+8+4+2 = 30 => gcd(6,30) = 6.
%p nn:=10^8:
%p for n from 1 to 60 do:
%p ii:=0:
%p for k from 1 to nn while(ii=0) do:
%p kk:=1:m:=k:T[kk]:=k:it:=0:
%p for i from 1 to nn while(m<>1) do:
%p if irem(m,2)=0
%p then
%p m:=m/2:kk:=kk+1:T[kk]:=m:
%p else
%p m:=3*m+1:kk:=kk+1:T[kk]:=m:
%p fi:
%p od:
%p s1:=0:s2:=0:
%p for j from 1 to kk do:
%p if irem(T[j],2)=1
%p then
%p s1:=s1+T[j]:
%p else
%p s2:=s2+T[j]:
%p fi:
%p od:
%p g:=gcd(s1,s2):
%p if g=n
%p then
%p ii:=1:printf("%d %d \n",n,k):
%p else fi:
%p od:
%p od:
%t Table[k = 1; While[n != GCD[Total@ Select[#, OddQ], Total@ Select[#, EvenQ]] &@ NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, k, # > 1 &], k++]; k, {n, 52}] (* _Michael De Vlieger_, Jul 13 2016 *)
%Y Cf. A213909, A213916.
%K nonn
%O 1,2
%A _Michel Lagneau_, Jul 13 2016
|