OFFSET
1,1
COMMENTS
Let s = (s(n)) be an increasing sequence of positive integers, and define sequences u = (u(n)) and v = (v(n)) as follows:
u(1) = s(1);
v(1) = least term of s that is >= u(1) + s(1);
u(n) = least term of s that is not in {u(k) : k < n} and not in {v(k) : k < n};
v(n) = least unused term of s that is greater than u(n) + s(n), for n >= 1.
Then u is the lower Wythoff partition sequence of s, and v is the upper Wythoff partition sequence of s.
MATHEMATICA
w[s_List] := Module[{u = {}, v = {}, used = <||>, n = 1, i = 1, target, vt},
While[i <= Length@s, While[i <= Length@s && KeyExistsQ[used, i], i++];
If[i > Length@s, Break[]]; AppendTo[u, s[[i]]]; used[i] = True;
target = u[[-1]] + s[[n]]; vt = -1; Do[If[! KeyExistsQ[used, j] && s[[j]] >= target, vt = j; Break[]], {j, 1, Length@s}]; If[vt == -1, u = Drop[u, -1]; Break[], AppendTo[v, s[[vt]]]; used[vt] = True; n++]; ]; {u, v}]
s = Prime[Range[200]]; (* User: put your increasing sequence s here *)
u = First[w[s]] (* lower Wythoff partition sequence of s *)
v = Last[w[s]] (* upper Wythoff partition sequence of s *)
(* Peter J. C. Moses, Dec 23 2025 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Clark Kimberling, Jan 19 2026
STATUS
approved
