A357554 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).
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, 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, 2, 3, 4, 4, 6, 6, 4, 4, 3, 2, 12, 1, 7, 5, 4, 5, 5, 7, 5, 5, 4, 5, 7, 13
Offset: 1
Examples
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. Triangle starts: 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, 2, 8; 1, 5, 3, 3, 5, 3, 3, 5, 9; 1, 2, 4, 4, 5, 5, 4, 4, 2, 10; ...
Links
- Robert Israel, Table of n, a(n) for n = 1..10011(rows 1 to 141, flattened)
Crossrefs
Cf. A357610.
Programs
-
Maple
g:= proc(n,k) local x,S; S:= {k}; x:= k; do x:= iquo(n,x) + irem(n,x); if member(x,S) then return x fi; S:= S union {x}; od end proc: for n from 1 to 20 do seq(g(n,k),k=1..n) od;
-
Mathematica
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}]]; Table[T[n, k], {n, 1, 20}, {k, 1, n}] // Flatten (* Jean-François Alcover, Oct 16 2022, after Robert Israel *)
-
Python
def T(n, k): seen, x = set(), k while x not in seen: seen.add(x); q, r = divmod(n, x); x = q + r return x print([T(n, k) for n in range(1, 14) for k in range(1, n+1)]) # Michael S. Branicky, Oct 04 2022
Formula
If k divides n, or if k > sqrt(n) and k^2-n is divisible by k-1, then T(n,k) = k.
T(n,2) = 2 if n is even, (n+1)/2 if n is odd.