%I #48 Jan 23 2025 00:31:50
%S 0,1,6,23,76,231,681,1968,5605,15817,44324,123573,343157,950000,
%T 2623530,7230746,19896140,54671729,150058028,411465352,1127315946,
%U 3086355718,8444524052,23092305853,63117665557,172444844373,470961842866,1285804853026,3509404275438,9575773901601
%N a(n) is the least integer m such that the distance of x_m from its nearest integer is less than 1/n, where x_m is the m-th extrema of gamma(x).
%C a(n) approximately equals exp(Pi/tan(Pi/n)).
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Gamma_function#Minima_and_maxima">Gamma Extrema</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Digamma_function#Roots_of_the_digamma_function">Digamma Roots</a>
%F A377376(a(n)) = n.
%e -1 + 1.46163214496836 < 1/1
%e 1 - 0.50408300826446 < 1/2
%e 6 - 5.66716244155689 < 1/3
%e 23 - 22.7502429843061 < 1/4
%e 76 - 75.8003723367285 < 1/5
%e 231 - 230.833395691244 < 1/6
%o (Python)
%o from gmpy2 import mpq, get_context, exp, digamma, sign, is_nan, RoundUp, RoundDown
%o def apply_on_interval(func, interval):
%o ctx.round = RoundUp
%o rounded_up = func(interval[0])
%o ctx.round = RoundDown
%o rounded_down = func(interval[1])
%o return rounded_down, rounded_up
%o def digamma_sign_near_int(i, f):
%o while True:
%o d, u = apply_on_interval(lambda x: digamma(i + 1/x), [f, f])
%o if not(is_nan(d)) and not(is_nan(u)) and (sign(d) == sign(u)): return sign(d)
%o ctx.precision += 1
%o def find_next_zero_crossing(f, i, growth_factor): # Bisect.
%o lo, hi = int(i * const_e), int(i * growth_factor)
%o while lo - 1 != hi:
%o if digamma_sign_near_int(mid := (hi + lo) // 2, f) == -1: lo = mid
%o else: hi = mid
%o return hi
%o def generate_sequence(n):
%o seq, frac_denoms = [0, 1, 6], (mpq(str(i)) for i in range(4, n + 1))
%o for f in frac_denoms: seq.append(-find_next_zero_crossing(f, -seq[-1], seq[-1] / seq[-2]))
%o return seq
%o const_e, ctx = exp(1), get_context()
%o ctx.precision = 2
%o A374856 = generate_sequence(30)
%Y Cf. A030169, A175472, A175473, A377376.
%K nonn
%O 1,3
%A _Jwalin Bhatt_, Sep 16 2024