OFFSET
1,2
EXAMPLE
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.
MAPLE
nn:=10^8:
for n from 1 to 60 do:
ii:=0:
for k from 1 to nn while(ii=0) do:
kk:=1:m:=k:T[kk]:=k:it:=0:
for i from 1 to nn while(m<>1) do:
if irem(m, 2)=0
then
m:=m/2:kk:=kk+1:T[kk]:=m:
else
m:=3*m+1:kk:=kk+1:T[kk]:=m:
fi:
od:
s1:=0:s2:=0:
for j from 1 to kk do:
if irem(T[j], 2)=1
then
s1:=s1+T[j]:
else
s2:=s2+T[j]:
fi:
od:
g:=gcd(s1, s2):
if g=n
then
ii:=1:printf("%d %d \n", n, k):
else fi:
od:
od:
MATHEMATICA
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 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Jul 13 2016
STATUS
approved