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-3 of 3 results.

A059876 a(n) = bin_prime_sum(n).

Original entry on oeis.org

2, 1, 3, 3, 5, 7, 9, -1, 1, 3, 5, 5, 7, 9, 11, 3, 5, 7, 9, 9, 11, 13, 15, 13, 15, 17, 19, 19, 21, 23, 25, -7, -5, -3, -1, -1, 1, 3, 5, 3, 5, 7, 9, 9, 11, 13, 15, 7, 9, 11, 13, 13, 15, 17, 19, 17, 19, 21, 23, 23, 25, 27, 29, -3, -1, 1, 3, 3, 5, 7, 9, 7, 9, 11, 13, 13, 15, 17, 19, 11, 13, 15, 17, 17, 19, 21, 23, 21, 23, 25, 27, 27, 29, 31, 33, 19, 21, 23, 25, 25, 27, 29, 31, 29, 31
Offset: 1

Views

Author

Antti Karttunen, Feb 05 2001

Keywords

Comments

From R. J. Mathar, Nov 12 2011: (Start)
The function bin_prime_sum of an argument n is a sum of three numbers. Let s = A000523(n) be the exponent of the largest power of 2 less than or equal to n and prime=A000040. Then the three terms are:
i) (-1)^(n+1);
ii) sum_{i=1..s} prime(i) * (1 + (-1)^[n/2^i] ); where [..] is the floor bracket;
iii) 1 (if n=1), otherwise prime(s) (if s even) or 0 (if s odd). (End)

Crossrefs

Programs

  • Maple
    with(numtheory); bin_prime_sum := proc(n) local i,s; s := floor_log_2(n); RETURN(((-1)^(n+1)) + add( (((-1)^(floor(n/(2^i))+1))*ithprime(i)),i=1..s) + (`if`((1 = n),1,((`mod`((s+1),2))*ithprime(s)))) ); end;
  • Mathematica
    a[n_] := With[{s = Floor[Log[2, n]]}, (-1)^(n+1) + Sum[(-1)^(Floor[n/2^i] + 1)*Prime[i], {i, 1, s}] + If[1 == n, 1, Mod[s+1, 2]*Prime[s]]]; Array[a, 105] (* Jean-François Alcover, Mar 07 2016, adapted from Maple *)

Formula

a(A059873(n)) = A000040(n).

A059873 The lexicographically earliest sequence of binary encodings of solutions satisfying the equation given in A059871.

Original entry on oeis.org

1, 3, 5, 13, 21, 46, 78, 175, 303, 639, 1143, 2539, 4542, 9214, 17406, 36735, 69374, 139254, 270327, 556031, 1079294, 2162678, 4259819, 8642558, 17022974, 34078590, 67632893, 136249338, 270401534, 541064701, 1077935867, 2162163707
Offset: 1

Views

Author

Antti Karttunen, Feb 05 2001

Keywords

Comments

The encoding is explained in A059872. Apply bin_prime_sum (see A059876) to this sequence and you get A000040, the prime numbers.

Crossrefs

Programs

  • Maple
    primesums_primes_search(16); primesums_primes_search := (upto_n) -> primesums_primes_search_aux([],1,upto_n); primesums_primes_search_aux := proc(a,n,upto_n) local i,p,t; if(n > upto_n) then RETURN(a); fi; p := ithprime(n); for i from (2^(n-1)) to ((2^n)-1) do t := bin_prime_sum(i); if(t = p) then print([op(a),i]); RETURN(primesums_primes_search_aux([op(a),i],n+1,upto_n)); fi; od; RETURN([op(a),`and no more found`]); end;

Extensions

More terms from Naohiro Nomoto, Sep 12 2001
More terms from Larry Reeves (larryr(AT)acm.org), Nov 20 2003

A059871 Number of solutions to the equation p_i = (1+mod(i,2))*p_{i-1} +- p_{i-2} +- p_{i-3} +- ... +- 2 +- 1, where p_i is the i-th prime number (where p_1 = 2 and the "zeroth prime" p_0 is defined to be 1).

Original entry on oeis.org

1, 1, 1, 1, 1, 3, 3, 4, 6, 12, 16, 31, 46, 90, 140, 276, 449, 877, 1443, 2834, 4725, 9395, 16153, 32037, 55872, 110288, 190815, 380488, 672728, 1342395, 2434797, 4808180, 8579625, 17070112, 30858078, 61271317, 110926277, 220979544, 402354848
Offset: 1

Views

Author

Antti Karttunen, Feb 05 2001

Keywords

Comments

In Burton's book it is said that it is "known" that each prime can be represented as such sum. However, I do not know whether that means it has been proved.
This is Scherk's theorem, which was conjectured by Scherk in 1833 and proved by Pillai in 1928. [T. D. Noe, Oct 03 2008]

Examples

			For the first five primes we have only one solution for each: 2 = 2*1, 3 = 1*2 + 1*1, 5 = 2*3 - 1*2 + 1*1, 7 = 1*5 + 1*3 - 1*2 + 1*1, 11 = 2*7 - 1*5 + 1*3 - 1*2 + 1*1 and for the next prime 13, we have 3 solutions: 13 = 11-7+5+3+2-1 = 11+7-5-3+2+1 = 11+7-5+3-2-1.
		

References

  • D. M. Burton, Elementary Number Theory.
  • S. S. Pillai, "On some empirical theorem of Scherk", J. Indian Math. Soc. 17 (1927-28), pp. 164-171.
  • W. Sierpiński, Elementary Theory of Numbers, Warszawa, 1964.

Crossrefs

See A059872 for the table of all solutions encoded as binary vectors and A059873-A059875 for specific sequences. A059876 gives the function bin_prime_sum.

Programs

  • Maple
    map(nops, primesums_primes_mult(16)); primesums_primes_mult := proc(upto_n) local a,b,i,n,p,t; a := []; for n from 1 to upto_n do b := []; p := ithprime(n); for i from (2^(n-1)) to ((2^n)-1) do t := bin_prime_sum(i); if(t = p) then b := [op(b),i]; fi; od; a := [op(a),b]; print(a); od; RETURN(a); end;
    # second Maple program
    p:= n-> `if`(n<0, 0, `if`(n=0, 1, ithprime(n))):
    sp:= proc(n) sp(n):= `if`(n<0, 0, p(n)+sp(n-1)) end:
    b := proc(n, i) option remember; `if`(n>sp(i), 0, `if`(i<0, 1,
            b(n+p(i), i-1)+ b(abs(n-p(i)), i-1)))
         end:
    a:= n-> b(p(n) -(1+irem(n, 2))*p(n-1), n-2):
    seq(a(n), n=1..40);  # Alois P. Heinz, Aug 05 2012
  • Mathematica
    nmax = 40; d = {1}; a1 = {}; pp = 1;
    Do[
      p = Prime[n];
      i = Ceiling[Length[d]/2] +  Abs[p - (1 + Mod[n, 2])*pp];
      AppendTo[a1, If[i > Length[d], 0, d[[i]]]];
      d = PadLeft[d, Length[d] + 2 pp] + PadRight[d, Length[d] + 2 pp];
      pp = p;
      , {n, nmax}];
    a1 (* Ray Chandler, Mar 11 2014 *)

Extensions

More terms from Naohiro Nomoto, Sep 11 2001
More terms from Larry Reeves (larryr(AT)acm.org), Nov 20 2003
a(33)-a(39) from Donovan Johnson, Oct 01 2010
Showing 1-3 of 3 results.