# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/
Search: id:a344583
Showing 1-1 of 1
%I A344583 #59 Jun 14 2021 11:54:44
%S A344583 0,0,0,1,2,2,1,3,5,4,2,3,7,5,3,7,5,8,4,2,3,10,5,2,16,5,5,13,9,2,7,2,
%T A344583 20,10,8,5,22,2,2,16,11,11,10,5,12,22,2,11,16,2,8,25,5,14,13,8,9,7,2,
%U A344583 8,10,8,5,31,20,18,16,15,12,7,5,8,49,8,12,16,2,8,16,5,27,40
%N A344583 Let f(k) = k/2 if k is even, otherwise (3*k+2*a(n)+1)/2, a(n) is the smallest integer greater than -1, where n = f^j(n) for j > 0 exists. f^j(n) means j times recursion into f(n).
%C A344583 This sequence is self-similar under multiplication by factor 3.
%C A344583 If Collatz conjecture is true, the only zeros in this sequence are a(0), a(1) and a(2).
%C A344583 This sequence could be extended to all non-integer numbers of the form n = a/3. This requires a generalization of "odd" and "even" such that if n is of the form n = m/(2*b+1), n will be considered as even when m is even. In this case the formula (a(3*n)-1)/a(n) = 3 will hold for fractional n too.
%H A344583 Thomas Scheuerle, Table of n, a(n) for n = 0..5000
%H A344583 Index entries for sequences related to 3x+1 (or Collatz) problem
%F A344583 a(n) <= (n-1)/2 for all odd n > 0.
%F A344583 (a(3*n)-1)/a(n) = 3 if n > 2.
%F A344583 a(2*n) >= a(n).
%e A344583 We may see this sequence as a sequence of functions:
%e A344583 0 -> f_0(k) = k/2 ; (3*k+1)/2.
%e A344583 1 -> f_1(k) = k/2 ; (3*k+3)/2.
%e A344583 2 -> f_2(k) = k/2 ; (3*k+5)/2.
%e A344583 a(58) = 2 because: f_2(58) = 58/2 = 29, f_2(29) = (29*3+2*2+1)/2 = 46, f_2(46) = 46/2 = 23, f_2(23) = (23*3+2*2+1)/2 = 37, f_2(37) = (37*3+2*2+1)/2 = 58.
%e A344583 This shows that f_2(f_2(f_2(f_2(f_2(58))))) = 58.
%e A344583 a(58) is not < 2 because no such loop which includes 58 exists for f_0 and f_1.
%o A344583 (MATLAB)
%o A344583 function a = A344583 ( max_n )
%o A344583 for n = 1:max_n
%o A344583 a_n = 0; stop = 0;
%o A344583 while stop == 0
%o A344583 v = [n]; k = n;
%o A344583 while length(v) == length(unique(v)) %run until results repeat
%o A344583 % Caution: If orbits without cycles exist, this may become
%o A344583 % an endless loop.
%o A344583 k = f( k,a_n );
%o A344583 v = [v k];
%o A344583 if k == n
%o A344583 a(n) = a_n;
%o A344583 stop = 1; break;
%o A344583 end
%o A344583 end
%o A344583 a_n = a_n+1;
%o A344583 end
%o A344583 end
%o A344583 end
%o A344583 function [ out ] = f( k,a_n )
%o A344583 if mod(k,2) == 0
%o A344583 out = k/2;
%o A344583 else
%o A344583 out = ((k*3) + (1+ 2*a_n))/2;
%o A344583 end
%o A344583 end
%o A344583 (PARI) isperiodic(v, z) = for (k=1, #v, if (v[k] == z, return(1)));
%o A344583 f(x, k) = if (x%2, (3*x+2*k+1)/2, x/2);
%o A344583 isok(k, n) = {my(v=[n], y=n); for (i=1, oo, my(z=f(y, k)); if (z == n, return (1)); if (isperiodic(v, z), return(0)); v = concat(v, z); y = z;);}
%o A344583 a(n) = {my(k=0); while (!isok(k, n), k++); k;} \\ _Michel Marcus_, Jun 14 2021
%K A344583 nonn
%O A344583 0,5
%A A344583 _Thomas Scheuerle_, May 24 2021
# Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE