Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #80 May 15 2023 08:43:05
%S 0,1,-2,2,-1,3,-4,4,-2,5,-10,6,-3,7,-9,8,-4,9,-15,10,-5,11,-14,12,-6,
%T 13,-24,14,-7,15,-19,16,-8,17,-28,18,-9,19,-24,20,-10,21,-42,22,-11,
%U 23,-29,24,-12,25,-41,26,-13,27,-34,28,-14,29,-53,30,-15,31,-39,32,-16,33,-54,34,-17,35,-44,36,-18,37,-71,38,-19,39,-49,40,-20,41,-67,42,-21,43,-54,44,-22,45,-82,46,-23,47,-59,48,-24,49,-80,50
%N In the Collatz 3x+1 problem: start at an odd number 2n+1 and find the next odd number 2m+1 in the trajectory; then a(n) = m-n.
%C Positive terms indicate the next odd number 2m+1 in the trajectory is greater than 2n+1 which is the case every second time giving a(n) = m-n = (n+1)/2.
%C Negative terms indicate the next odd number 2m+1 in the trajectory is smaller than 2n+1. For behavior of this part refer to A087230.
%H Ruud H.G. van Tol, <a href="/A246425/b246425.txt">Table of n, a(n) for n = 0..20000</a>
%H Ruud H.G. van Tol, <a href="/A246425/a246425_1.txt">Perl program</a>
%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%F a(n) = ((6*n+4)/2^A087230(n) - (2*n+1))/2.
%e a(14)=-9 because 2*14 + 1 = 29 and the Collatz trajectory to reach the next odd number goes: 29, 88, 44, 22, 11. Thus, m=5 and 5 - 14 = -9.
%p f:= proc(n) local m;
%p m:= 6*n+4;
%p m/2^(1+padic:-ordp(m,2))-n-1/2
%p end proc:
%p map(f, [$0..100]); # _Robert Israel_, Mar 22 2020
%t a[n_] := ((6n+4)/2^IntegerExponent[6n+4, 2] - (2n+1))/2;
%t Table[a[n], {n, 0, 100}] (* _Jean-François Alcover_, May 15 2023 *)
%o (PARI) forstep(n=0, 1000, 1, m=6*n+4; print1(((m/2^valuation(m, 2)-(2*n+1))/2),", "))
%Y Cf. A005408, A075677, A087230, A349414.
%K sign,nice,look
%O 0,3
%A _K. G. Stier_, Aug 26 2014