I’ve been looking at the value N(n) of N that satisfies the equation
Thus turns out to be
where the O(1/n) term is about 1/400n for n>10.
I’ve verified this by calculation up to about n=1000, using Lenstra’s long integer package LIP.
This result is so beautiful and simple that it must be possible to prove it without brute-force calculation. If anyone has any suggestions as to how to begin then I’d be very grateful.