OFFSET
1,3
EXAMPLE
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.
PROG
(Haskell)
f = go 0 2
where
go a r n
| n >= c = go (a+t) (r+1) (n-c)
| n >= r*div n r + m = a + 2*div n r + 1
| n >= r*div n r + m' + 1 = a + 2*div n r + 1
| otherwise = a + 2*div n r
where
t = totient r
c = div (r*t) 2
m = midnum r
m' = midnum (r-1)
midnum r = head [a|a<-[div (r+1) 2..], gcd a r==1]
CROSSREFS
KEYWORD
nonn
AUTHOR
Carl Edman, May 23 2017
STATUS
approved