A277068 a(n) = gcd(s1, s2), 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 n.
1, 1, 1, 1, 6, 1, 18, 1, 3, 2, 1, 1, 1, 2, 2, 1, 2, 21, 1, 6, 2, 1, 3, 1, 2, 1, 2, 6, 2, 4, 2, 1, 1, 4, 2, 3, 1, 1, 2, 2, 3, 2, 2, 1, 1, 1, 1, 1, 2, 12, 2, 1, 1, 2, 2, 2, 1, 4, 3, 4, 2, 2, 2, 1, 5, 1, 1, 4, 2, 2, 2, 3, 1, 7, 2, 1, 1, 2, 2, 6, 7, 1, 1, 2, 2, 8
Offset: 1
Keywords
Examples
a(5)=6 because the Collatz trajectory of 5 is 5 -> 16 -> 8 -> 4 -> 2 -> 1 => s1 = 5+1 = 6, s2 = 16+8+4+2 = 30, and gcd(6, 30) = 6.
Links
- Michel Lagneau, Table of n, a(n) for n = 1..10000
- Robert G. Wilson v, The first occurrence of a(n)
Programs
-
Maple
nn:=10^7: for n from 1 to 100 do: m:=n:s1:=0:s2:=0: for i from 1 to nn while(m<>1) do: if irem(m,2)=0 then s2:=s2+m:m:=m/2: else s1:=s1+m:m:=3*m+1: fi: od: x:=gcd(s1+1,s2): printf(`%d, `,x): od:
-
Mathematica
Collatz[n_] := NestWhileList[ If[ OddQ[#], 3#+1, #/2] &, n, # > 1 &]; f[n_] := Block[{c = Collatz@ n}, GCD[Plus @@ Select[c, OddQ], Plus @@ Select[c, EvenQ]]]; Array[f, 86] (* Robert G. Wilson v, Oct 03 2016 *)
-
PARI
a(n) = {my(se = 0); my(so = 0); while (n!=1, if (n % 2, so+=n; n = 3*n+1, se +=n; n = n/2);); gcd(se, so+1);} \\ Michel Marcus, Oct 03 2016
Comments