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.

Previous Showing 41-48 of 48 results.

A113037 Number of solutions to +- 1 +- 2 +- .. +- n = 3.

Original entry on oeis.org

0, 0, 1, 0, 0, 3, 5, 0, 0, 23, 39, 0, 0, 219, 396, 0, 0, 2406, 4435, 0, 0, 28431, 53167, 0, 0, 353500, 667874, 0, 0, 4557831, 8675836, 0, 0, 60382450, 115601178, 0, 0, 816998489, 1571272955, 0, 0, 11242173783, 21701318843, 0, 0, 156841667096
Offset: 0

Views

Author

Floor van Lamoen, Oct 11 2005

Keywords

Crossrefs

Programs

  • Maple
    A113037:= proc(n) local i,j,p,t; t:= NULL; for j to n do p:=1; for i to j do p:=p*(x^(-i)+x^i); od; t:=t,coeff(p,x,3); od; t; end;
  • Mathematica
    nmax = 50; d = {1}; a1 = {};
    Do[
      i = Ceiling[Length[d]/2] + 3;
      AppendTo[a1, If[i > Length[d], 0, d[[i]]]];
      d = PadLeft[d, Length[d] + 2 n] + PadRight[d, Length[d] + 2 n];
      , {n, nmax}];
    a1 (* Ray Chandler, Mar 14 2014 *)

Formula

a(n) is the coefficient of x^3 in product(x^(-k)+x^k, k=1..n).

A293576 Numbers n such that the set of exponents in expression for 2*n as a sum of distinct powers of 2 can be partitioned into two parts with equal sums.

Original entry on oeis.org

0, 7, 13, 15, 22, 25, 27, 30, 39, 42, 45, 47, 49, 51, 54, 59, 60, 62, 75, 76, 82, 85, 87, 90, 93, 95, 97, 99, 102, 107, 108, 110, 117, 119, 120, 122, 125, 127, 141, 143, 147, 148, 153, 155, 158, 162, 165, 167, 170, 173, 175, 179, 180, 185, 187, 188, 190, 193
Offset: 1

Views

Author

Rémy Sigrist, Oct 12 2017

Keywords

Comments

More informally, this sequence encodes finite sets of positive numbers, say { e_1, e_2, ..., e_h }, such that +- e_1 +- e_2 ... +- e_h = 0 has a solution.
The set of exponents in expression for n as a sum of distinct powers of 2 corresponds to the n-th row of A133457.
No term can have a Hamming weight of 1 or 2.
If x and y belong to this sequence and x AND y = 0 (where AND stands for the bitwise and-operator), then x + y belongs to this sequence.
If k has an odd Hamming weight, then there are only a finite number of terms with the same odd part as k (see A000265 for the odd part of a number).
The number 2^k-1 belongs to this sequence iff A063865(k) > 0.
If k has Hamming weight > 1, then k + 2^(A029931(k)-1) belongs to this sequence.

Examples

			2*42 = 2^6 + 2^4 + 2^2 and 6 = 4 + 2, hence 42 appears in the sequence.
2*11 = 2^4 + 2^2 + 2^1 and { 1, 2, 4 } cannot be partitioned into two parts with equals sums, hence 11 does not appear in the sequence.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, t) option remember; `if`(n=0, is(t=0),
          (i-> b(n-2^i, t-i) or b(n-2^i, t+i))(ilog2(n)))
        end:
    a:= proc(n) option remember; local k; for k from 1+
         `if`(n=1, -1, a(n-1)) while not b(2*k, 0) do od; k
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Oct 22 2017
  • PARI
    is(n) = { my (v=Set(0)); my (b = Vecrev(binary(n))); for (i=1, #b, if (b[i], v = set union(Set(vector(#v, k, v[k]-i)), Set(vector(#v, k, v[k]+i))););); return (set search(v,0)); }

A325538 Number of subsets of {1..n} whose product is one more than the sum of their complement.

Original entry on oeis.org

1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 2, 0, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 0, 4, 2, 2, 4, 2, 2, 5, 5, 1, 2, 2, 3, 2, 5, 3, 4, 2, 2, 3, 10, 2, 4, 7, 5, 3, 3, 7, 6, 4, 4, 5, 5, 5, 2, 6, 4, 6, 5, 3, 8, 4, 5, 4, 5, 2, 10, 5, 3, 7, 11, 6, 10, 5, 11, 6, 4, 7, 6, 10
Offset: 0

Views

Author

Gus Wiseman, Jul 07 2019

Keywords

Comments

Also by definition the number of subsets whose sum is one fewer than the product of their complement.

Examples

			The initial terms count the following subsets:
   0: {}
   1: {1}
   2: {2}
   3: {1,3}
   4: {2,3}
   7: {4,5}
  10: {1,6,7}
  12: {7,9}
  12: {1,2,4,8}
  14: {2,5,9}
  14: {1,2,4,11}
  15: {1,3,5,7}
  16: {3,4,10}
  16: {1,3,5,8}
  17: {1,10,13}
  18: {2,5,15}
  19: {11,15}
  19: {1,2,6,14}
  20: {1,4,6,8}
		

Crossrefs

Programs

  • Mathematica
    Table[Length[Select[Subsets[Range[n]],1+Plus@@#==Times@@Complement[Range[n],#]&]],{n,0,10}]
    ric[n_, pr_, s_, lst_, t_] := Block[{k}, If[pr == t-s, cnt++]; Do[ If[pr k <= t, ric[n, pr k, s + k, k, t], Break[]], {k, lst+1, n}]]; a[n_] := (cnt = 0; ric[n, 1, 0, 0, n (n + 1)/2 + 1]; cnt); a /@ Range[0, 85] (* Giovanni Resta, Sep 13 2019 *)

Extensions

More terms from Alois P. Heinz, Jul 12 2019

A342602 Number of solutions to 1 +-* 2 +-* 3 +-* ... +-* n = 0.

Original entry on oeis.org

0, 0, 1, 1, 1, 4, 6, 14, 29, 63, 129, 300, 756, 1677, 4134, 9525, 22841, 57175, 141819, 354992, 882420, 2218078, 5588989, 14173217, 35918542
Offset: 1

Views

Author

Scott R. Shannon, Mar 27 2021

Keywords

Comments

Normal operator precedence is followed, so multiplication is performed before addition or subtraction. Unlike A058377, which uses only addition and subtraction, this sequence has solutions for all values of n >= 3.
The author thanks Ursula Ponting for useful discussions.

Examples

			a(3) = 1 as 1 + 2 - 3 = 0 is the only solution.
a(4) = 1 as 1 - 2 - 3 + 4 = 0 is the only solution.
a(5) = 1 as 1 * 2 - 3 - 4 + 5 = 0 is the only solution. This is the first term where a solution exists while no corresponding solution exists in A058377.
a(6) = 4. The solutions, all of which use multiplication, are
         1 + 2 * 3 + 4 - 5 - 6 = 0,
         1 - 2 + 3 * 4 - 5 - 6 = 0,
         1 - 2 * 3 + 4 - 5 + 6 = 0,
         1 * 2 + 3 - 4 + 5 - 6 = 0.
a(10) = 63. An example solution is
         1 - 2 * 3 * 4 - 5 - 6 - 7 * 8 + 9 * 10 = 0.
a(20) = 354992. An example solution is
         1 * 2 * 3 * 4 * 5 * 6 * 7 + 8 * 9 + 10 * 11 - 12 * 13 + 14 * 15
             - 16 * 17 * 18 - 19 * 20 = 0
  which includes thirteen multiplications.
		

Crossrefs

Cf. A342804 (using +-*/), A342995 (using +-/), A058377 (using +-), A063865, A000217, A025591, A161943.

Programs

  • Mathematica
    Table[Length@Select[Tuples[{"+","-","*"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,11}] (* Giorgos Kalogeropoulos, Apr 02 2021 *)
  • Python
    from itertools import product
    def a(n):
      nn = [str(i) for i in range(1, n+1)]
      return sum(eval("".join([*sum(zip(nn, ops+("",)), ())])) == 0 for ops in product("+-*", repeat=n-1))
    print([a(n) for n in range(1, 14)]) # Michael S. Branicky, Apr 02 2021

A342995 Number of solutions to 1 +-/ 2 +-/ 3 +-/ ... +-/ n = 0.

Original entry on oeis.org

0, 0, 1, 1, 0, 1, 4, 8, 0, 3, 37, 80, 6, 17, 461, 868, 190, 364, 5570, 11342, 3993, 7307, 78644
Offset: 1

Views

Author

Scott R. Shannon, Apr 01 2021

Keywords

Comments

Normal operator precedence is followed, so division is performed before addition or subtraction. Unlike A058377, which uses only addition and subtraction, this sequence has solutions for all values of n >= 10.

Examples

			a(3) = 1 as 1 + 2 - 3 = 0 is the only solution.
a(4) = 1 as 1 - 2 - 3 + 4 = 0 is the only solution.
a(5) = 0, as in A058377.
a(6) = 1 as 1 - 2 / 3 / 4 - 5 / 6 = 0 is the only solution. This is the first term where a solution exists while no corresponding solution exists in A058377.
a(8) = 8. Seven of the solutions involve just addition and subtraction, matching those in A058377, but one additional solution exists using division:
        1 / 2 / 3 / 4 + 5 / 6 - 7 / 8 = 0.
a(10) = 3. All three solutions require division:
        1 + 2 / 3 / 4 + 5 / 6 + 7 - 8 + 9 - 10 = 0,
        1 - 2 / 3 / 4 - 5 / 6 + 7 - 8 - 9 + 10 = 0,
        1 - 2 / 3 / 4 - 5 / 6 - 7 + 8 + 9 - 10 = 0.
a(15) = 461. Of these, 361 use only addition and subtraction, the other 100 also require division. One example of the latter is
        1 / 2 / 3 / 4 - 5 - 6 - 7 / 8 + 9 / 10 + 11 + 12 - 13 + 14 / 15 = 0.
a(20) = 11342. An example solution is
        1 / 2 / 3 - 4 / 5 / 6 + 7 / 8 / 9 + 10 + 11 / 12 - 13 + 14 / 15 / 16
             + 17 / 18 + 19 / 20 = 0
  which sums seven fractions that include eleven divisions.
		

Crossrefs

Cf. A342804 (using +-*/), A342602 (using +-*), A058377 (using +-), A063865, A000217, A025591, A161943.

Programs

  • Mathematica
    Table[Length@Select[Tuples[{"+","-","/"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,11}] (* Giorgos Kalogeropoulos, Apr 02 2021 *)
  • Python
    from itertools import product
    from fractions import Fraction
    def a(n):
      nn = ["Fraction("+str(i)+", 1)" for i in range(1, n+1)]
      return sum(eval("".join([*sum(zip(nn, ops+("",)), ())])) == 0 for ops in product("+-/", repeat=n-1))
    print([a(n) for n in range(1, 11)]) # Michael S. Branicky, Apr 02 2021

A369873 a(n) is the constant term in the expansion of Product_{d|n} (x^d + 1/x^d).

Original entry on oeis.org

0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 6, 0, 0, 0, 2, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 4, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 4, 0, 2, 0, 0, 0, 34, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 6, 0, 0, 0, 28, 0, 0, 0, 2, 0, 26, 0, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 4, 0, 2, 0
Offset: 1

Views

Author

Ilya Gutkovskiy, Feb 03 2024

Keywords

Comments

a(n) is the number of solutions to 0 = Sum_{d|n} c_i * d with c_i in {-1,1}, i=1..tau(n), tau = A000005.

Crossrefs

Programs

  • Mathematica
    Table[Coefficient[Product[(x^d + 1/x^d), {d, Divisors[n]}], x, 0], {n, 1, 90}]
  • PARI
    A369873(n) = { my(s=sigma(n),p=1); if(s%2 || s < 2*n, 0, fordiv(n, d, p *= ('x^d + 'x^-d)); polcoeff(p, 0)); }; \\ (cf. also code in A083206 and A379504) - Antti Karttunen, Jan 20 2025
  • Python
    from collections import Counter
    from sympy import divisors
    def A369873(n):
        c = {0:1}
        for d in divisors(n,generator=True):
            b = Counter()
            for j in c:
                a = c[j]
                b[j+d] += a
                b[j-d] += a
            c = b
        return c[0] # Chai Wah Wu, Feb 05 2024
    

Formula

From Joerg Arndt, Feb 04 2024: (Start)
a(n) != 0 (only) for n in A083207.
a(n) = 2 * A083206(n). (End)

Extensions

Data section extended to a(105) by Antti Karttunen, Jan 20 2025

A379451 Number of ordered ways of writing 0 as Sum_{k=-n..n} e(k)*k, where e(k) is 0 or 1.

Original entry on oeis.org

2, 10, 162, 6278, 430906, 46032666, 7029940154, 1453778429782, 390651831405906, 132345369222827306, 55150093300481888770, 27727437337790844360198, 16545310955942988999292586, 11561068480810074519638819626, 9349537740123803513263001013354, 8664632430514446774520557369434870
Offset: 0

Views

Author

Ilya Gutkovskiy, Dec 23 2024

Keywords

Examples

			a(1) = 10 ways: {}, {0}, {-1, 1} (2 permutations), {-1, 0, 1} (6 permutations).
		

Crossrefs

Programs

  • Python
    from math import factorial
    from functools import cache
    @cache
    def b(i, s, c):
        if i == 0: return factorial(c) if s == 0 else 0
        return b(i-1, s, c) + b(i-1, s+(i>>1)*(-1)**(i&1), c+1)
    def a(n): return b(2*n+1, 0, 0)
    print([a(n) for n in range(16)]) # Michael S. Branicky, Dec 23 2024

Extensions

a(9) and beyond from Michael S. Branicky, Dec 23 2024

A174600 T(n,k) = 1 if the sum of +-k..+-n with arbitrary signs never equals zero, = 0 otherwise (lower triangle).

Original entry on oeis.org

1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1
Offset: 1

Views

Author

R. H. Hardin Mar 23 2010, with formula and reference from Franklin T. Adams-Watters and Olivier Gérard, on the Sequence Fans Mailing list

Keywords

Examples

			Triangle begins
1;
1, 1;
0, 1, 1;
0, 1, 1, 1;
1, 0, 1, 1, 1;
1, 0, 0, 1, 1, 1;
0, 1, 1, 0, 1, 1, 1;
0, 1, 1, 0, 0, 1, 1, 1;
1, 0, 0, 1, 1, 0, 1, 1, 1;
1, 0, 0, 1, 1, 1, 0, 1, 1, 1; ...
		

Crossrefs

Related to A063865.

Programs

  • AWK
    { for(n=1; n<10; n++)
            for(k=1; k<=n; k++)
                print ++i, T(n,k);
    }
    function T(n,k) {
        if ( int((n+1)/2)%2 != int(k/2)%2 ) return 1;
        else if ( (n-k)%2 == 0 ) {
            if ( k > ((n-k)/2)^2 ) return 1;
            else return 0;
        }
        else return 0;
    }
    
  • Mathematica
    t[n_, k_] := If[Mod[Floor[(n+1)/2], 2] != Mod[Floor[k/2], 2], 1, If[Mod[n-k, 2] == 0, If[k > ((n-k)/2)^2, 1, 0], 0]]; Flatten[Table[t[n, k], {n, 1, 15}, {k, 1, n}]][[;; 108]] (* Jean-François Alcover, Jul 11 2011, after awk program *)
  • PARI
    T(n,k)=
    {
        if ( ((n+1)\2)%2 != (k\2)%2,
            return(1);
        , /* else */
            if ( (n-k)%2 == 0,
                if ( k > ((n-k)/2)^2, return(1), return(0) );
            , /* else */
                return(0);
            );
        );
    }
    { for(n=1, 10, /* show triangle */
        for(k=1,n,
            print1(T(n,k),", ");
        );
        print();
     ); }
Previous Showing 41-48 of 48 results.