login
Cardinality of the largest subset of {1,...,n} such that no odd number of terms from this subset multiply to a square.
5

%I #72 Jun 01 2024 06:17:45

%S 0,1,2,2,3,3,4,5,5,5,6,7,8,9,9,9,10,11,12,12,13,13,14,15,15,16,17,18,

%T 19,19,20,20,20,21,21,21,22,23,23,24,25,26,27,28,29,30,31,31,31,31,32,

%U 33,34,34,34,35,36,37,38,39,40,41,42,42,42,43,44,45,46,46,47

%N Cardinality of the largest subset of {1,...,n} such that no odd number of terms from this subset multiply to a square.

%H Martin Ehrenstein, <a href="/A373114/b373114.txt">Table of n, a(n) for n = 1..550</a> (terms 72..181 calculated from A360659)

%H A. Granville and K. Soundararajan, <a href="https://doi.org/10.2307/2661346">The spectrum of multiplicative functions</a>, Ann. Math. 153 (2001), 407-470; <a href="https://arxiv.org/abs/math/9909190">preprint</a>, arXiv:math/9909190 [math.NT], 1999.

%H Terence Tao, <a href="https://arxiv.org/abs/2405.11610">On product representations of squares</a>, arXiv:2405.11610 [math.NT], May 2024.

%F n-2*a(n) = A360659(n) (see Footnote 2 of the linked paper of Tao).

%F Asymptotically, a(n)/n converges to log(1+sqrt(e)) - 2*Integral_{t=1..sqrt(e)} log(t)/(t+1) dt = A246849 ~ 0.828499... (essentially due to Granville and Soundararajan).

%F a(n+1)-a(n) is either 0 or 1 for any n.

%F a(n) >= A055038(n).

%e For n=6, {2,3,5} is the largest set without an odd product being a square, so a(6)=3.

%o (Python)

%o import itertools

%o import sympy

%o def generate_all_completely_multiplicative_functions(primes):

%o combinations = list(itertools.product([-1, 1], repeat=len(primes)))

%o functions = []

%o for combination in combinations:

%o func = dict(zip(primes, combination))

%o functions.append(func)

%o return functions

%o def evaluate_function(f, n):

%o if n == 1:

%o return 1

%o factors = sympy.factorint(n)

%o value = 1

%o for prime, exp in factors.items():

%o value *= f[prime] ** exp

%o return value

%o def compute_minimum_sum(N: int):

%o primes = list(sympy.primerange(1, N + 1))

%o functions = generate_all_completely_multiplicative_functions(primes)

%o min_sum = float("inf")

%o for func in functions:

%o total_sum = 0

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

%o total_sum += evaluate_function(func, n)

%o if total_sum < min_sum:

%o min_sum = total_sum

%o return min_sum

%o results = [(N - compute_minimum_sum(N)) // 2 for N in range(1, 12)]

%o print(", ".join(map(str, results)))

%o (Python)

%o from itertools import product

%o from sympy import primerange, primepi, factorint

%o def A373114(n):

%o a = dict(zip(primerange(n+1),range(c:=primepi(n))))

%o return n-min(sum(sum(e for p,e in factorint(m).items() if b[a[p]])&1^1 for m in range(1,n+1)) for b in product((0,1),repeat=c)) # _Chai Wah Wu_, May 31 2024

%o (PARI)

%o F(n, b)={vector(n, k, my(f=factor(k)); prod(i=1, #f~, if(bittest(b, primepi(f[i, 1])-1), 1, -1)^f[i, 2]))}

%o a(n)={my(m=oo); for(b=0, 2^primepi(n)-1, m=min(m, vecsum(F(n, b)))); (n-m)/2} \\ adapted from Andrew Howroyd, Feb 16 2023 at A360659 by _David A. Corneth_, May 25 2024

%Y Closely related to A360659, A372306, A373119, A373178, A373195.

%Y Cf. A055038, A246849.

%K nonn

%O 1,3

%A _Terence Tao_, May 25 2024

%E More terms from _David A. Corneth_, May 25 2024 using b-file from A360659 and formula n-2*a(n) = A360659(n)