login
Least k such that Sum_{i=1..n} (-k)^i / i is a positive integer.
2

%I #9 Apr 02 2020 19:04:08

%S 1,2,6,6,30,20,140,140,210,42,462,462,12012,3432,6006,6006,87516,

%T 87516,1108536,3048474,2586584,2586584,44618574,44618574,60843510,

%U 17160990,17160990,14263680,782050830,782050830,3806842470,3806842470,16830250920,16830250920

%N Least k such that Sum_{i=1..n} (-k)^i / i is a positive integer.

%C Note that the denominator of (Sum_{i=1..n} (-k)^i/i) - (-k)^p/p can never be divisible by p, where n/2 < p <= n. Therefore, for the expression to be an integer, such p must divide k. Thus, a(n) = k is divisible by A055773(n).

%H Chai Wah Wu, <a href="/A333073/b333073.txt">Table of n, a(n) for n = 1..60</a>

%F a(n) <= A034386(n).

%o (PARI) a(n) = {my(m = prod(i=primepi(n/2)+1, primepi(n), prime(i)), k = m); while(denominator(sum(i=2, n, (-k)^i/i)) != 1, k += m); k; }

%o (Python)

%o from sympy import primorial, lcm

%o def A333073(n):

%o f = 1

%o for i in range(1,n+1):

%o f = lcm(f,i)

%o f = int(f)

%o glist = []

%o for i in range(1,n+1):

%o glist.append(f//i)

%o m = 1 if n < 2 else primorial(n,nth=False)//primorial(n//2,nth=False)

%o k = m

%o while True:

%o p,ki = 0, -k

%o for i in range(1,n+1):

%o p = (p+ki*glist[i-1]) % f

%o ki = (-k*ki) % f

%o if p == 0:

%o return k

%o k += m # _Chai Wah Wu_, Apr 02 2020

%Y Cf. A034386, A055773, A333072, A333074.

%K nonn

%O 1,2

%A _Jinyuan Wang_, Mar 31 2020