cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-7 of 7 results.

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

Views

Author

Keywords

Examples

			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.
		

Crossrefs

Programs

  • Maple
    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
  • Mathematica
    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 *)
  • Python
    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
    
  • Python
    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

Formula

a(n) = A127180(n) - A200744(n) = A200744(n) - A038667(n) = (A127180(n) - A038667(n)) / 2. - Max Alekseyev, Jun 18 2022

Extensions

a(24)-a(30) from Alois P. Heinz, Nov 22 2011
a(31) from Michael S. Branicky, May 21 2021

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

Views

Author

Keywords

Examples

			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.
		

Crossrefs

Programs

  • Maple
    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
  • Mathematica
    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 *)
  • Python
    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

Formula

a(n) = A127180(n) - A200743(n) = A038667(n) + A200743(n) = (A038667(n) + A127180(n)) / 2. - Max Alekseyev, Jun 18 2022

Extensions

a(24)-a(30) from Alois P. Heinz, Nov 22 2011

A061057 Factorial splitting: write n! = x*y with x <= y and x maximal; sequence gives value of y-x.

Original entry on oeis.org

0, 1, 1, 2, 2, 6, 2, 18, 54, 30, 36, 576, 127, 840, 928, 3712, 20160, 93696, 420480, 800640, 1305696, 7983360, 55056804, 65318400, 326592000, 2286926400, 2610934480, 13680979200, 18906930876, 674165366496, 326850970500, 16753029012720, 16880461678080
Offset: 1

Views

Author

Ed Pegg Jr, May 28 2001

Keywords

Comments

Difference between central divisors of n!. - Jaume Oliver Lafont, Mar 13 2009
For n > 1, n! will never be a square, because of primes in the last half of the factors. Therefore the divisors of n! come in pairs (x,y) with x*y = n! and x < y. The sequence gives the difference y-x between the pair nearest to the square root of n!. - Alois P. Heinz, Jul 06 2009
a(n) = 2 iff n belongs to A146968. - Max Alekseyev, Feb 06 2010

Examples

			2! = 1*2, with difference of 1.
3! = 2*3, with difference of 1.
4! = 4*6, with difference of 2.
5! = 10*12, with difference of 2.
6! = 24*30, with difference of 6.
7! = 70*72 with difference of 2.
The corresponding central divisors are two units apart (equivalently, n!+1=A038507(n) is a square) for n = 4, 5, 7 (see A146968).
		

Crossrefs

Programs

  • Maple
    A060777 := proc(n) local d,nd ; d := sort(convert(numtheory[divisors](n!),list)) ; nd := nops(d) ; op(floor(1+nd/2),d) ; end:
    A060776 := proc(n) local d,nd ; d := sort(convert(numtheory[divisors](n!),list)) ; nd := nops(d) ; op(floor(nd/2),d) ; end:
    A061057 := proc(n) A060777(n)-A060776(n) ; end:
    seq(A061057(n),n=2..27) ; # R. J. Mathar, Mar 14 2009
  • Mathematica
    Do[ With[ {k = Floor[ Sqrt[ x! ] ] - Do[ If[ Mod[ x!, Floor[ Sqrt[ x! ] ] - n ] == 0, Return[ n ] ], {n, 0, 10000000} ]}, Print[ {x, "! =", k, x!/k, x!/k - k} ] ], {x, 3, 22} ]
    f[n_] := Block[{k = Floor@ Sqrt[n! ]}, While[ Mod[n!, k] != 0, k-- ]; n!/k - k]; Table[f@n, {n, 2, 32}] (* Robert G. Wilson v, Jul 11 2009 *)
    Table[d=Divisors[n!]; len=Length[d]; If[OddQ[len], 0, d[[1 + len/2]] - d[[len/2]]], {n, 34}] (* Vincenzo Librandi, Jan 02 2016 *)
  • PARI
    for(k=2,25,d=divisors(k!);print(d[#d/2+1]-d[#d/2])) \\ Jaume Oliver Lafont, Mar 13 2009
    
  • Python
    from math import isqrt, factorial
    from sympy import divisors
    def A061057(n):
        k = factorial(n)
        m = max(d for d in divisors(k,generator=True) if d <= isqrt(k))
        return k//m-m # Chai Wah Wu, Apr 06 2022

Formula

a(n) = A060777(n) - A060776(n).
a(n) = A056737(A000142(n)). - Pontus von Brömssen, Jul 15 2023

Extensions

More terms from Dean Hickerson, Jun 13 2001
Edited by N. J. A. Sloane Jul 07 2009 at the suggestion of R. J. Mathar and Alois P. Heinz
a(41) from Robert G. Wilson v, Oct 03 2014

A061060 Write product of first n primes as x*y with x

Original entry on oeis.org

1, 1, 1, 1, 13, 17, 1, 41, 157, 1811, 1579, 18859, 95533, 17659, 1995293, 208303, 2396687, 58513111, 299808329, 2460653813, 3952306763, 341777053, 115405393057, 437621467859, 1009861675153, 6660853109087, 29075165225531
Offset: 1

Views

Author

Ed Pegg Jr, May 28 2001

Keywords

Examples

			a(4)=1: 2*3*5*7 = 210 = 14*15, so we can take x=14, y=15, with difference of 1.
Also: n=3: 2*3-5=1; n=4: 3*5-2*7=1; n=5: 5*11-2*3*7=13; n=6: 2*7*13-3*5*11=17; n=7: 5*11*13-2*3*7*17=1; n=8: 3*5*11*19-2*7*13*17=41
		

Crossrefs

Programs

  • Maple
    A061060aux := proc(l1,l2) local resul ; resul := product(l1[i],i=1..nops(l1)) ; resul := resul-product(l2[i],i=1..nops(l2)) ; RETURN(abs(resul)) ; end:
    A061060 := proc(n) local plist,i,subl,resul,j,l1,l2,k,d ; plist := [] ; resul := 1 ; for i from 1 to n do resul := resul*ithprime(i) ; plist := [op(plist), ithprime(i)] ; od; for i from 1 to n/2 do subl := combinat[choose](plist,i) ; for j from 1 to nops(subl) do l1 := op(j,subl) ; l2 := convert(plist,set) minus convert(l1,set) ; d := A061060aux(l1,l2) ; if d < resul then resul := d ; fi ; od; od ; RETURN(resul) ; end:
    for n from 3 to 19 do printf("%d,",A061060(n)) ; od ; # R. J. Mathar, Aug 26 2006 [This Maple program was attached to A121315. However I think it belongs here, so I renamed the variables and moved it to this entry. - N. J. A. Sloane, Sep 16 2005]
  • Mathematica
    (* first do *) Needs["DiscreteMath`Combinatorica`"] (* then *) f[n_] := Block[{arrayofnprimes = Array[Prime, n], primorial = Times @@ Array[Prime, n], diffmin = Infinity, adiff, sub}, If[n == 1, 1, Do[sub = Times @@ NthSubset[i, arrayofnprimes]; adiff = Abs[primorial/sub - sub]; If[adiff < diffmin, diffmin = adiff], {i, 2, 2^n/2}]; diffmin]]; Do[ Print@f@n, {n, 30}] (* Robert G. Wilson v, Sep 14 2006 *)

Formula

Conjecture: Limit_{N->oo} (Sum_{n=1..N} log(a(n))) / (Sum_{n=1..N} prime(n)) = 1/e (A068985). - Alain Rocchelli, Nov 13 2023

Extensions

Terms a(16)-a(45) in b-file computed by Jud McCranie, Apr 15 2000; Jan 12 2016
a(46)-a(60) in b-file from Don Reble, Jul 11 2020
a(61)-a(70) in b-file from Max Alekseyev, Apr 20 2022

A127180 a(n) = smallest possible (product of b(k)'s + product of c(k)'s), where the positive integers <= n are partitioned somehow into {b(k)} and {c(k)}.

Original entry on oeis.org

2, 2, 3, 5, 10, 22, 54, 142, 402, 1206, 3810, 12636, 43776, 157824, 590520, 2287080, 9148320, 37719360, 160029696, 697553280, 3119552640, 14295585696, 67052240640, 321571257120, 1575370944000, 7876854720000, 40164235953600
Offset: 0

Views

Author

Leroy Quet, Jan 07 2007

Keywords

Comments

The maximum (product of b(k)'s + product of c(k)'s) occurs, for n>=2, when {b(k)} = (2,3,4,...n) and {c(k)} = (1). a(1) = 2 because the product over the empty set is defined here as 1.

Examples

			By partitioning (1,2,3,...8) into {b(k)} and {c(k)} so that {b(k)} = (1,4,6,8) and {c(k)} = (2,3,5,7), then (product of b(k)'s + product of c(k)'s) is minimized. Therefore a(8) = 1*4*6*8 + 2*3*5*7 = 402.
		

Crossrefs

Programs

  • Maple
    LQprod := proc(S) if nops(S) = 0 then 1 ; else product(S[i],i=1..nops(S)) ; fi ; end: A127180 := proc(n) local S,m,B,b,c,s,res,i ; res := -1 ; S := {} ; for i from 1 to n do S := S union {i} ; od; for m from 0 to n/2 do B := combinat[permute](n,m) ; for i from 1 to nops(B) do b := op(i,B) ; c := S minus convert(b,set) ; s := LQprod(b)+LQprod(c) ; if res < 0 or s < res then res := s ; fi ; od ; od ; RETURN(res) ; end: for n from 1 to 20 do A127180(n) ; od ; # R. J. Mathar, Jan 10 2007
  • Mathematica
    a[n_] := a[n] = Module[{s, t}, {s, t} = MinimalBy[{#, Complement[Range[n], #]}& /@ Subsets[Range[n]], Abs[Times @@ #[[1]] - Times @@ #[[2]]]&][[1]]; Times @@ s + Times @@ t];
    Table[Print[n, " ", a[n]]; a[n], {n, 0, 24}] (* Jean-François Alcover, May 06 2023 *)

Formula

a(n) <= A060696(n+1) = A076051(n) considering the interleaved partition b={2,4,6,..}, c={1,3,5, 7,...}. - R. J. Mathar, Jan 10 2007
a(n) = A200743(n) + A200744(n) = (A200744(n)^2 - A200743(n)^2) / A038667(n). - Max Alekseyev, Apr 08 2022

Extensions

a(9)-a(13) from R. J. Mathar, Jan 10 2007
a(14)-a(26) from Ray Chandler, Feb 14 2007

A263292 Number of distinct values of |product(A) - product(B)| where A and B are a partition of {1,2,...,n}.

Original entry on oeis.org

1, 1, 1, 2, 4, 8, 13, 26, 44, 76, 119, 238, 324, 648, 1008, 1492, 2116, 4232, 5680, 11360, 15272, 21872, 33536, 67072, 83168, 121376, 185496, 249072, 328416, 656832, 790656, 1581312, 1980192, 2758624, 4193040, 5555616, 6532896, 13065792, 19845216
Offset: 0

Views

Author

Jerrold Grossman, Oct 13 2015

Keywords

Comments

The problem of showing that no number k is equal to |product(A)-product(B)| for infinitely many different values of n appears in a Hungarian journal for high school students in math and physics (see KöMaL link).
Compare to A038667, which provided the smallest value of |product(A) - product(B)|.
Also the number of distinct values <= sqrt(n!) of element products of subsets of [n]. - Alois P. Heinz, Oct 17 2015

Examples

			For n = 4, the four possible values of |product(A) - product(B)| are 2, 5, 10, and 23.
		

Crossrefs

Cf. A038667.

Programs

  • Maple
    b:= proc(n) option remember; local f, g, h;
          if n<2 then {1}
        else f, g, h:= n!, y-> `if`(y^2<=f, y, NULL), (n-1)!;
             map(x-> {x, g(x*n), g(h/x)}[], b(n-1))
          fi
        end:
    a:= n-> nops(b(n)):
    seq(a(n), n=0..25);  # Alois P. Heinz, Oct 17 2015
  • Mathematica
    a[n_] := Block[{v = Times @@@ Subsets[ Range[2, n], Floor[n/2]]}, Length@ Union@ Abs[v - n!/v]]; Array[a, 20] (* Giovanni Resta, Oct 17 2015 *)
  • Python
    from math import prod, factorial
    from itertools import combinations
    def A263292(n):
        m = factorial(n)
        return 1 if n == 0 else len(set(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 07 2022

Extensions

a(21)-a(27) from Giovanni Resta, Oct 17 2015
a(28)-a(38) from Alois P. Heinz, Oct 17 2015

A352813 Minimum difference |product(A) - product(B)| where A and B are a partition of {1,2,3,...,2*n} and |A| = |B| = n.

Original entry on oeis.org

0, 1, 2, 6, 18, 30, 576, 840, 24480, 93696, 800640, 7983360, 65318400, 2286926400, 13680979200, 797369149440, 16753029012720, 10176199188480, 159943859712000, 26453863460044800, 470500040794291200, 20720967220237197312, 61690805562507264000
Offset: 0

Views

Author

Peter J. Taylor, Apr 04 2022

Keywords

Comments

a(n) >= A038667(2*n).
Conjecture: a(n) = A038667(2*n) for all n. It is verified for n<=70. - Max Alekseyev, Jun 18 2022
Bernardo Recamán Santos proposes that this should be called Luciana's sequence for the student whose question prompted its investigation. (See MathOverflow link below.)

Examples

			For n = 4, the partition A = {1,5,6,7} and B = {2,3,4,8} is optimal, giving difference 1*5*6*7 - 2*3*4*8 = 18.
_Rob Pratt_ computed the optimal solutions for n <= 10:
[ n]    a(n)                   partitions of 2n
------------------------------------------------------------------
[ 1]       1                         2 | 1
[ 2]       2                       2,3 | 1,4
[ 3]       6                     1,5,6 | 2,3,4
[ 4]      18                   1,5,6,7 | 2,3,4,8
[ 5]      30                2,3,4,8,10 | 1,5,6,7,9
[ 6]     576              1,4,7,8,9,11 | 2,3,5,6,10,12
[ 7]     840           2,4,5,6,8,11,14 | 1,3,7,9,10,12,13
[ 8]   24480        1,5,6,7,8,13,14,15 | 2,3,4,9,10,11,12,16
[ 9]   93696     2,3,6,8,9,11,12,13,18 | 1,4,5,7,10,14,15,16,17
[10]  800640  2,3,4,8,9,11,12,18,19,20 | 1,5,6,7,10,13,14,15,16,17
		

Crossrefs

Programs

  • Python
    from math import prod, factorial
    from itertools import combinations
    def A352813(n):
        m = factorial(2*n)
        return 0 if n == 0 else min(abs((p:=prod(d))-m//p) for d in combinations(range(2,2*n+1),n-1)) # Chai Wah Wu, Apr 06 2022
  • Sage
    def A352813(n):
        return min(abs(prod(A)-prod(B)) for (A,B) in SetPartitions((1..2*n), [n,n]))
    [A352813(n) for n in (1..10)] # Freddy Barrera, Apr 05 2022
    
Showing 1-7 of 7 results.