%I #22 Aug 13 2024 11:30:41
%S 1,1,1,1,2,1,3,1,3,2,5,1,6,3,4,1,4,3,9,2,6,5,11,1,10,6,9,3,14,4,5,1,5,
%T 4,12,3,18,9,12,2,10,6,7,5,12,11,23,1,21,10,8,6,26,9,20,3,9,14,29,4,
%U 30,5,6,1,6,5,33,4,22,12,35,3,9,18,20,9,30,12
%N a(n) is the length of the cycle of the trajectory of 1/n under the map f(x) = min(2*x, 2-2*x).
%C For any rational number q in the interval [0, 1]:
%C - f(q) is rational and lies in the interval [0, 1],
%C - denominator(f(q)) <= denominator(q),
%C - as there are only finitely many rational numbers whose denominator is less than or equal to that of q in the interval [0, 1],
%C - iteratively applying f to q eventually leads to a cycle,
%C - and the sequence is well defined.
%C For any irrational number x in the interval [0, 1]:
%C - f(x) is irrational and lies in the interval [0, 1],
%C - for any k > 0, as fixed points of the k-th iterate of f are rational,
%C - iteratively applying f to x never leads to a cycle.
%C As f is continuous on the interval [0, 1] and 1/7 has least period 3, according to the period three theorem, f has points of any period length, as well as chaotic points.
%H Roman Khrabrov, <a href="/A309786/b309786.txt">Table of n, a(n) for n = 1..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PeriodThreeTheorem.html">Period Three Theorem</a>
%F a(2*n-1) = A003558(n-1).
%F a(2*n) = a(n).
%F a(n) = 1 iff n belongs to A029744.
%F a(n) = 2 iff n belongs to A020714.
%e For n = 5:
%e - f(1/5) = 2/5,
%e - f(2/5) = 4/5,
%e - f(4/5) = 2/5,
%e - hence a(5) = 2.
%o (PARI) a(n, f=x -> min(2*x, 2-2*x)) = my (x=f(1/n), y=f(x)); while (x!=y, x=f(x); y=f(f(y))); for (k=1, oo, if (x==y=f(y), return (k)))
%Y Cf. A003558, A020714, A029744.
%K nonn
%O 1,5
%A _Rémy Sigrist_, Aug 17 2019