%I #33 Oct 16 2022 16:35:37
%S 1,1,2,1,2,3,1,2,2,4,1,3,3,3,5,1,2,3,3,2,6,1,4,3,4,3,4,7,1,2,4,4,4,4,
%T 2,8,1,5,3,3,5,3,3,5,9,1,2,4,4,5,5,4,4,2,10,1,6,3,5,5,6,5,5,3,6,11,1,
%U 2,3,4,4,6,6,4,4,3,2,12,1,7,5,4,5,5,7,5,5,4,5,7,13
%N Triangular array read by rows. For T(n,k) where 1 <= k <= n, start with x = k and repeat the map x -> floor(n/x) + (n mod x) until an x occurs that has already appeared, then that is T(n,k).
%H Robert Israel, <a href="/A357554/b357554.txt">Table of n, a(n) for n = 1..10011</a>(rows 1 to 141, flattened)
%F If k divides n, or if k > sqrt(n) and k^2-n is divisible by k-1, then T(n,k) = k.
%F T(n,2) = 2 if n is even, (n+1)/2 if n is odd.
%e For T(13,2) we have 2 -> floor(13/2) + (13 mod 2) = 7 -> floor(13/7) + (13 mod 7) = 7 so T(13,2) = 7.
%e Triangle starts:
%e 1;
%e 1, 2;
%e 1, 2, 3;
%e 1, 2, 2, 4;
%e 1, 3, 3, 3, 5;
%e 1, 2, 3, 3, 2, 6;
%e 1, 4, 3, 4, 3, 4, 7;
%e 1, 2, 4, 4, 4, 4, 2, 8;
%e 1, 5, 3, 3, 5, 3, 3, 5, 9;
%e 1, 2, 4, 4, 5, 5, 4, 4, 2, 10;
%e ...
%p g:= proc(n,k) local x,S;
%p S:= {k};
%p x:= k;
%p do
%p x:= iquo(n,x) + irem(n,x);
%p if member(x,S) then return x fi;
%p S:= S union {x};
%p od
%p end proc:
%p for n from 1 to 20 do seq(g(n,k),k=1..n) od;
%t T[n_, k_] := Module[{x, S}, S = {k}; x = k; While[True, x = Quotient[n, x] + Mod[n, x]; If[MemberQ[S, x], Return[x]]; S = S~Union~{x}]];
%t Table[T[n, k], {n, 1, 20}, {k, 1, n}] // Flatten (* _Jean-François Alcover_, Oct 16 2022, after _Robert Israel_ *)
%o (Python)
%o def T(n, k):
%o seen, x = set(), k
%o while x not in seen: seen.add(x); q, r = divmod(n, x); x = q + r
%o return x
%o print([T(n, k) for n in range(1, 14) for k in range(1, n+1)]) # _Michael S. Branicky_, Oct 04 2022
%Y Cf. A357610.
%K nonn,tabl,look
%O 1,3
%A _J. M. Bergot_ and _Robert Israel_, Oct 02 2022