A200743
Divide integers 1..n into two sets, minimizing the difference of their products. This sequence is the smaller product.
Original entry on oeis.org
1, 1, 2, 4, 10, 24, 70, 192, 576, 1890, 6300, 21600, 78624, 294840, 1140480, 4561920, 18849600, 79968000, 348566400, 1559376000, 7147140000, 33522128640, 160745472000, 787652812800, 3938264064000, 20080974513600, 104348244639744, 552160113120000, 2973491173785600, 16286186592000000, 90678987245246400
Offset: 1
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.
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) = 78624.
-
a:= proc(n) local l, ll, g, 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 (mmbb 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])); g(1, nops(l), 1) end: seq(a(n), n=1..23); # Alois P. Heinz, Nov 22 2011
-
a[n_] := a[n] = Module[{s, t}, {s, t} = MinimalBy[{#, Complement[Range[n], #]}& /@ Subsets[Range[n]], Abs[Times @@ #[[1]] - Times @@ #[[2]]]&][[1]]; Min[Times @@ s, Times @@ t]];
Table[Print[n, " ", a[n]]; a[n], {n, 1, 25}] (* Jean-François Alcover, Nov 03 2020 *)
-
from itertools import combinations
def prod(l):
t=1
for x in l:
t *= x
return t
def a200743(n):
nums = list(range(1,n+1))
widths = combinations(nums,n//2)
dimensions = [(prod(width),prod(x for x in nums if x not in width)) for width in widths]
best = min(dimensions,key=lambda x:max(*x)-min(*x))
return min(best)
# Christian Perfect, Feb 04 2015
-
from math import prod, factorial
from itertools import combinations
def A200743(n):
m = factorial(n)
return min((abs((p:=prod(d))-m//p),min(p,m//p)) for l in range(n,n//2,-1) for d in combinations(range(1,n+1),l))[1] # Chai Wah Wu, Apr 07 2022
A200744
Divide integers 1..n into two sets, minimizing the difference of their products. This sequence is the larger product.
Original entry on oeis.org
1, 2, 3, 6, 12, 30, 72, 210, 630, 1920, 6336, 22176, 79200, 295680, 1146600, 4586400, 18869760, 80061696, 348986880, 1560176640, 7148445696, 33530112000, 160825785120, 787718131200, 3938590656000, 20083261440000, 104351247000000, 552173794099200, 2973528918360000, 16286983961149440
Offset: 1
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.
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.
-
a:= proc(n) local l, ll, g, 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 (mmbb 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])); ll[n]/ g(1, nops(l), 1) end: seq(a(n), n=1..23); # Alois P. Heinz, Nov 22 2011
-
a[n_] := a[n] = Module[{s, t}, {s, t} = MinimalBy[{#, Complement[Range[n], #]}& /@ Subsets[Range[n]], Abs[Times @@ #[[1]] - Times @@ #[[2]]]&][[1]]; Max[Times @@ s, Times @@ t]];
Table[Print[n, " ", a[n]];
a[n], {n, 1, 25}] (* Jean-François Alcover, Nov 07 2020 *)
-
from math import prod, factorial
from itertools import combinations
def A200744(n):
m = factorial(n)
return min((abs((p:=prod(d))-m//p),max(p,m//p)) for l in range(n,n//2,-1) for d in combinations(range(1,n+1),l))[1] # Chai Wah Wu, Apr 07 2022
A038667
Minimal value of |product(A) - product(B)| where A and B are a partition of {1,2,3,...,n}.
Original entry on oeis.org
0, 0, 1, 1, 2, 2, 6, 2, 18, 54, 30, 36, 576, 576, 840, 6120, 24480, 20160, 93696, 420480, 800640, 1305696, 7983360, 80313120, 65318400, 326592000, 2286926400, 3002360256, 13680979200, 37744574400, 797369149440, 1763653953600, 16753029012720, 16880461678080, 10176199188480, 26657309952000
Offset: 0
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.
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.
-
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 (mmbb 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:
seq(a(n), n=0..20); # Alois P. Heinz, Jul 09 2009, revised Oct 17 2015
-
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 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 *)
-
from math import prod, factorial
from itertools import combinations
def A038667(n):
m = factorial(n)
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
A182987
Least a + b such that a*b = A002110(n), the product of the first n primes, where a, b are positive integers.
Original entry on oeis.org
2, 3, 5, 11, 29, 97, 347, 1429, 6229, 29873, 160879, 895681, 5448239, 34885673, 228759799, 1568299433, 11417382973, 87698582693, 684947829299, 5606539600699, 47241542381273, 403631914511993, 3587558929043927, 32684217334524347, 308342289648328511, 3036819365023723883
Offset: 0
a(3) = 11 = min{ 2*3 + 5 = 11, 2*5 + 3 = 13, 3*5 + 2 = 17 }
Or, a(3) = 11 = min { 1+30, 2+15, 3+10, 5+6 } because A002110(3) = 2*3*5 = 30 = 2*15 = 3*10 = 5*6.
- Max Alekseyev, Table of n, a(n) for n = 0..70
- David Broadhurst, Re: adding to prime number [primes in A182987], primenumbers group, Sep 20 2011.
- David Broadhurst and others, Adding to prime number, digest of 28 messages in primenumbers Yahoo group, Sep 19, 2011 - Sep 22, 2011.
-
a[0] = 2; a[n_] := Module[{m = Times @@ Prime[Range[n]]}, For[an = 2 Floor[Sqrt[m]] + 1, an <= m + 2, an += 2, If[IntegerQ[Sqrt[an^2 - 4 m]], Return[an]]]]; Table[an = a[n]; Print[an]; an, {n, 0, 25}] (* Jean-François Alcover, Oct 20 2016, adapted from PARI *)
-
A182987(n)={if(n,vecsum(divisors(vecprod(primes(n)))[2^(n-1)..2^(n-1)+1]),2)} \\ Needs stack size >= 2^(n+6). - M. F. Hasler, Sep 20 2011, edited Mar 24 2022
-
A182987(n)={ n||return(2); my(m=prod(k=1,n,prime(k))); forstep(a=2*sqrtint(m)+1,m+2,2, issquare(a^2-4*m) & return(a)) } \\ Slow for n >= 28, but needs not much memory. - M. F. Hasler, following an idea from David Broadhurst, Sep 20 2011
-
def A182987(n): # becomes slow for n >= 28, but not slower than memory-hungry
# sum(divisors(primorial(n))[2**(n-1)-1:2**(n-1)+1]) if n else 2
"Compute A182987(n) = sum of the two central divisors of primorial(n)."
if n < 2: return n+2
from math import isqrt # = A000196
from sympy import primorial # = A002110
from sympy.ntheory.primetest import is_square # = A010052
m = primorial(n)*4; a = isqrt(m)|1 ### ceil(sqrt(m))**2 < m for n = 26..27 !!
while True:
if is_square(a*a - m): return a
a += 2
# M. F. Hasler, Mar 21 2022
First term and example corrected, as empty sets have product 1, by
Phil Carmody, Sep 20 2011
Simpler definition and extension to n = 0 by
M. F. Hasler, Sep 20 2011
b-file extended to a(59) with results from R. Gerbicz (cf. 2nd Broadhurst link) by
M. F. Hasler, Mar 22 2022
A127181
a(1)=a(2)=1. a(n) = smallest possible (product of b(k)'s + product of c(k)'s), where the sequence's terms a(1) through a(n-1) are partitioned somehow into {b(k)} and {c(k)}.
Original entry on oeis.org
1, 1, 2, 3, 5, 11, 37, 221, 3361, 190777, 83199527, 760382931109, 662056785094857629, 538451433632092674800570837, 12495147956629620251492228703104952798089, 1397663545252630798358314360015943050984074671707253231083973
Offset: 1
By partitioning (a(1),a(2),...a(7)) = (1,1,2,3,5,11,37) into {b(k)} and {c(k)} so that {b(k)} = (1,2,5,11) and {c(k)} = (1,3,37), then (product of b(k)'s + product of c(k)'s) is minimized. Therefore a(8) = 1*2*5*11 + 1*3*37 = 221.
-
Nest[ Module[ {prod=Times@@#1}, Append[ #,Min[ #+prod/#&/@Times@@@Union[ Subsets[ # ] ] ] ] ]&,{1,1,2,3},12 ] (* Peter Pein (petsie(AT)dordos.net), Jan 07 2007 *)
a(10)-a(15) from Peter Pein (petsie(AT)dordos.net), Jan 07 2007
Showing 1-5 of 5 results.
Comments