%I #36 Dec 04 2015 23:34:59
%S 2,3,6,3,3,12,9,3,18,3,7,24,7,9,30,3,7,36,25,7,42,7,15,48,33,7,54,9,
%T 19,60,27,21,66,7,15,72,43,25,78,7,27,84,57,19,90,15,27,96,43,33,102,
%U 7,15,108,73,37,114,19,39,120,27,27,126,21,43,132,39,45
%N a(n) = smallest initial value s such that n is in the Collatz trajectory of s (s is not regarded as part of its trajectory).
%C The initial term is not counted as an element of the trajectory.
%C For even n obviously a(n) <= 2n, because the halving step would reach n. - _R. J. Mathar_, Nov 27 2015
%H Michel Lagneau, <a href="/A261814/b261814.txt">Table of n, a(n) for n = 1..5000</a>
%e a(1)=2 because the number 1 is in the trajectory 2 -> 1;
%e a(2)=3 because the number 2 is in the trajectory 3 -> 10 -> 5 -> ... -> 2 -> 1;
%e a(3)=6 because the number 3 is in the trajectory 6 -> 3 -> 10 -> ... -> 1;
%e a(4)=3 because the number 4 is in the trajectory 3 -> 10 -> 5 -> ... -> 4 -> 2 -> 1.
%p Collatz := proc(n)
%p if type(n,'even') then
%p n/2;
%p else
%p 3*n+1 ;
%p end if;
%p end proc:
%p CollatzTrj := proc(x,membSrch)
%p local t;
%p t := x ;
%p while t <> 1 do
%p t := Collatz(t) ;
%p if t = membSrch then
%p return true ;
%p end if;
%p end do:
%p return false;
%p end proc:
%p A261814 := proc(n)
%p for x from 2 do
%p if CollatzTrj(x,n) then
%p return x;
%p end if;
%p end do;
%p end proc: # _R. J. Mathar_, Nov 27 2015
%Y Cf. A006577, A260303, A260389.
%K nonn
%O 1,1
%A _Michel Lagneau_, Nov 22 2015
|