%I #68 Sep 13 2023 23:00:52
%S 0,0,1,1,2,2,6,2,18,54,30,36,576,576,840,6120,24480,20160,93696,
%T 420480,800640,1305696,7983360,80313120,65318400,326592000,2286926400,
%U 3002360256,13680979200,37744574400,797369149440,1763653953600,16753029012720,16880461678080,10176199188480,26657309952000
%N Minimal value of |product(A) - product(B)| where A and B are a partition of {1,2,3,...,n}.
%C Conjecture: The sequence of rational numbers A061057(n)/a(n) has 1 as a limit point. Question: What other limit points does the sequence have? - _Richard Peterson_, Jul 13 2023
%H Max Alekseyev, <a href="/A038667/b038667.txt">Table of n, a(n) for n = 0..140</a> (terms for n = 0..60 from Peter J. Taylor)
%F a(n) = A200744(n) - A200743(n) = (A200744(n)^2 - A200743(n)^2) / A127180(n). - _Max Alekseyev_, Apr 08 2022
%F a(n) >= A061057(n).
%e For n=1, we put 1 in one set and the other is empty; with the standard convention for empty products, both products are 1.
%e For n=13, the central pair of divisors of n! are 78975 and 78848. Since neither is divisible by 10, these values cannot be obtained. The next pair of divisors are 79200 = 12*11*10*6*5*2*1 and 78624 = 13*9*8*7*4*3, so a(13) = 79200 - 78624 = 576.
%p a:= proc(n) local l, ll, g, gg, p, i; l:= [i$i=1..n]; ll:= [i!$i=1..n]; g:= proc(m, j, b) local mm, bb, k; if j=1 then m else mm:= m; bb:= b; for k to 2 while (mm<p) do if j=2 or k=2 or k=1 and ll[j-1]*mm>bb then bb:= max(bb, g(mm, j-1, bb)) fi; mm:= mm*l[j] od; bb fi end; Digits:= 700; p:= ceil(sqrt(ll[n])); gg:= g(1, nops(l), 1); ll[n]/gg -gg end: a(0):=0:
%p seq(a(n), n=0..20); # _Alois P. Heinz_, Jul 09 2009, revised Oct 17 2015
%t a[n_] := Module[{l, ll, g, gg, p, i}, l = Range[n]; ll = Array[Factorial, n]; g[m_, j_, b_] := g[m, j, b] = Module[{mm, bb, k}, If[j==1, m, mm=m; bb=b; For[k=1, mm<p, k++, If[j==2 || k==2 || k==1 && ll[[j-1]]*mm > bb , bb = Max[bb, g[mm, j-1, bb]]]; mm = mm*l[[j]]]; bb]]; p = Ceiling[Sqrt[ ll[[n]]]]; gg = g[1, Length[l], 1]; ll[[n]]/gg - gg]; a[0]=0; Table[an = a[n]; Print["a(", n, ") = ", an]; an, {n, 0, 35}] (* _Jean-François Alcover_, Feb 29 2016, after _Alois P. Heinz_ *)
%o (Python)
%o from math import prod, factorial
%o from itertools import combinations
%o def A038667(n):
%o m = factorial(n)
%o return 0 if n == 0 else min(abs((p:=prod(d))-m//p) for l in range(n,n//2,-1) for d in combinations(range(1,n+1),l)) # _Chai Wah Wu_, Apr 06 2022
%Y Cf. A061033, A061057, A061060, A200743, A200744, A127180, A263292.
%K nonn
%O 0,5
%A _Erich Friedman_
%E a(28)-a(31) from _Alois P. Heinz_, Jul 09 2009
%E a(1) and examples from _Franklin T. Adams-Watters_, Nov 22 2011
%E a(32)-a(33) from _Alois P. Heinz_, Nov 23 2011
%E a(34)-a(35) from _Alois P. Heinz_, Oct 17 2015
|