Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #14 May 26 2017 21:24:58
%S 1,1,2,3,3,3,4,5,5,5,6,6,7,7,7,8,8,9,9,9,9,10,10,11,11,11,11,12,12,12,
%T 13,13,13,13,14,14,14,15,15,15,15,16,16,16,17,17,17,17,17,18
%N Order of largest subset of the positive rationals with neither the sum of numerators nor of denominators exceeding n.
%e For n = 1, the largest subset is { 1/1 }, so a(1) = 1; for n = 2, the same; for n = 3, largest subsets are { 1/1, 2/1 } and { 1/2, 1/1 }, so a(3) = 2; for n = 4, the largest subset is { 1/2, 1/1, 2/1 }, so a(4) = 3; ...; for n = 16, the largest subset is { 1/4, 1/3, 1/2, 2/3, 1/1, 2/1, 3/1, 4/1 } (or swap 2/3 for 3/2), so a(16)=8, etc.
%o (Haskell)
%o f = go 0 2
%o where
%o go a r n
%o | n >= c = go (a+t) (r+1) (n-c)
%o | n >= r*div n r + m = a + 2*div n r + 1
%o | n >= r*div n r + m' + 1 = a + 2*div n r + 1
%o | otherwise = a + 2*div n r
%o where
%o t = totient r
%o c = div (r*t) 2
%o m = midnum r
%o m' = midnum (r-1)
%o midnum r = head [a|a<-[div (r+1) 2..], gcd a r==1]
%K nonn
%O 1,3
%A _Carl Edman_, May 23 2017