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-10 of 22 results. Next

A054845 Number of ways of representing n as the sum of one or more consecutive primes.

Original entry on oeis.org

0, 0, 1, 1, 0, 2, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 2, 1, 1, 0, 0, 0, 2, 1, 0, 1, 0, 1, 1, 1, 2, 0, 0, 0, 0, 2, 1, 0, 1, 0, 3, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 2, 0, 0, 1, 0, 1, 2, 2, 1, 0, 0, 0, 0, 0, 2, 1, 0, 0, 2, 2, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 3, 1, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 1, 0, 2, 1, 0, 2, 2
Offset: 0

Views

Author

Jud McCranie, May 25 2000

Keywords

Comments

Moser shows that the average order of a(n) is log 2, that is, Sum_{i=1..n} a(i) ~ n log 2. This shows that a(n) = 0 infinitely often (and with positive density); Moser asks if a(n) = 1 infinitely often, if a(n) = k is solvable for all k, whether these have positive density, and whether the sequence is bounded. - Charles R Greathouse IV, Mar 21 2011

Examples

			a(5)=2 because of 2+3 and 5. a(17)=2 because of 2+3+5+7 and 17.
41 = 41 = 11+13+17 = 2+3+5+7+11+13, so a(41)=3.
		

References

  • R. K. Guy, Unsolved Problems In Number Theory, C2.

Crossrefs

Programs

  • Magma
    S:=[0]; for n in [1..104] do count:=0; for q in PrimesUpTo(n) do p:=q; s:=p; while s lt n do p:=NextPrime(p); s+:=p; end while; if s eq n then count+:=1; end if; end for; Append(~S, count); end for; S; // Klaus Brockhaus, Feb 17 2011
    
  • Maple
    A054845 := proc(n)
        local a,mipri,npr,ps ;
        a := 0 ;
        for mipri from 1 do
            for npr from 1 do
                ps := add(ithprime(i),i=mipri..mipri+npr-1) ;
                if ps = n then
                    a := a+1 ;
                elif ps >n then
                    break;
                end if;
            end do:
            if ithprime(mipri) > n then
                break ;
            end if;
        end do:
        a ;
    end proc: # R. J. Mathar, Nov 27 2018
  • Mathematica
    f[n_] := Block[{p = Prime@ Range@ PrimePi@ n}, len = Length@ p; Count[(Flatten[#, 1] &)[Table[ p[[i ;; j]], {i, len}, {j, i, len}]], q_ /; Total@ q == n]]; f[0] = 0; Array[f, 102, 0](* Jean-François Alcover, Feb 16 2011 *) (* fixed by Robert G. Wilson v *)
    nn=100; p=Prime[Range[PrimePi[nn]]]; t=Table[0,{nn}]; Do[s=0; j=i; While[s=s+p[[j]]; s<=nn,t[[s]]++; j++], {i,Length[p]}]; Join[{0},t]
  • PARI
    {/* program gives values of a(n) for n=0..precprime(nn)-1 */
    nn=2000;t=vector(nn+1);forprime(x=2,nn,s=x;
    forprime(y=x+1,nn,if(s<=nn,t[s+1]++,break());s=s+y));t[1..precprime(nn)]} \\ Zak Seidov, Feb 17 2011, corrected by Michael S. Branicky, Feb 28 2022
    
  • Perl
    use ntheory ":all"; my $n=10000; my @W=(0)x($n+1); forprimes { my $s=$; do { $W[$s]++; $s += ($=next_prime($)); } while $s <= $n; } $n; print "$ $W[$]\n" for 0..$#W;  # _Dana Jacobsen, Aug 22 2018
    
  • Python
    from sympy import primerange
    def aupton(nn): # modification of PARI by Zak Seidov
        alst = [0 for n in range(nn+1)]
        for x in primerange(2, nn+1):
            s = x
            alst[s] += 1
            for y in primerange(x+1, nn+1):
                s += y
                if s <= nn:
                    alst[s] += 1
                else:
                    break
        return alst
    print(aupton(101)) # Michael S. Branicky, Feb 17 2022
    
  • Python
    # alternate version for going to large n
    import heapq
    from sympy import prime
    from itertools import islice
    def agen(): # generator of terms
        p = v = prime(1); h = [(p, 1, 1)]; nextcount = 2; oldv = ways = 0
        while True:
            (v, s, l) = heapq.heappop(h)
            if v == oldv: ways += 1
            else:
                yield ways
                for n in range(oldv+1, v): yield 0
                ways = 1
            if v >= p:
                p += prime(nextcount)
                heapq.heappush(h, (p, 1, nextcount))
                nextcount += 1
            oldv = v
            v -= prime(s); s += 1; l += 1; v += prime(l)
            heapq.heappush(h, (v, s, l))
    print(list(islice(agen(), 102))) # Michael S. Branicky, Feb 17 2022

Formula

G.f.: Sum_{i>=1} Sum_{j>=i} Product_{k=i..j} x^prime(k). - Ilya Gutkovskiy, Apr 18 2019

Extensions

Edited by N. J. A. Sloane, Oct 27 2008 at the suggestion of Jake M. Foster

A067381 Smallest prime expressible as the sum of (at least two) consecutive primes in n ways.

Original entry on oeis.org

5, 41, 311, 311, 34421, 442019, 3634531, 48205429, 1798467197, 36154343837, 166400805323, 6123584726269
Offset: 1

Views

Author

Patrick De Geest, Feb 04 2002

Keywords

Comments

a(9)-a(11) found by Wilfred Whiteside in 2007.

Examples

			5 can be represented (in just one way) as 2+3.
		

Crossrefs

Extensions

a(12) from Giovanni Resta, May 07 2020

A054996 Integers that can be expressed as the sum of consecutive primes in exactly 1 way.

Original entry on oeis.org

2, 3, 7, 8, 10, 11, 12, 13, 15, 18, 19, 24, 26, 28, 29, 30, 37, 39, 42, 43, 47, 48, 49, 52, 56, 58, 61, 68, 73, 75, 77, 78, 79, 84, 88, 89, 95, 98, 102, 103, 107, 113, 121, 124, 128, 129, 132, 137, 144, 149, 150, 151, 155, 156, 157, 158, 159, 160, 161, 162, 163
Offset: 1

Views

Author

Jud McCranie, May 30 2000

Keywords

Examples

			8=3+5, so 8 is in the sequence.
		

References

  • R. K. Guy, Unsolved Problems in Number Theory, section C2.

Crossrefs

Formula

A054845(a(n)) = 1. - Ray Chandler, Sep 20 2023

A054998 Integers that can be expressed as the sum of consecutive primes in exactly 3 ways.

Original entry on oeis.org

41, 83, 197, 199, 223, 240, 251, 281, 287, 340, 371, 401, 439, 491, 510, 593, 660, 733, 803, 857, 864, 883, 931, 941, 961, 983, 990, 991, 1012, 1060, 1061, 1099, 1104, 1187, 1236, 1283, 1313, 1361, 1381, 1392, 1433, 1439, 1493, 1511, 1523, 1524, 1553
Offset: 1

Views

Author

Jud McCranie, May 30 2000

Keywords

Examples

			41 can be expressed as 41 or 11+13+17 or 2+3+5+7+11+13, so 41 is in the sequence.
		

References

  • R. K. Guy, Unsolved Problems in Number Theory, section C2.

Crossrefs

Programs

  • Maple
    N:= 10^4: # to get all terms <= N
    P:= [0,op(select(isprime, [2,seq(i,i=3..N,2)]))]:
    nP:= nops(P);
    S:= ListTools:-PartialSums(P):
    V:= Vector(N):
    for i from 1 to nP-1 do
      for j from i+1 to nP while S[j] - S[i] <= N do
         V[S[j]-S[i]]:= V[S[j]-S[i]]+1
    od od:
    select(t -> V[t] = 3, [$1..N]): # Robert Israel, Apr 05 2017
  • Mathematica
    Module[{nn = 300, s}, s = Array[Prime, nn]; Keys@ Take[Select[KeySort@ Merge[Table[PositionIndex@ Map[Total, Partition[s, k, 1]], {k, nn/2}], Identity], Length@ # == 3 &], Floor[nn/6]]] (* Michael De Vlieger, Apr 06 2017, Version 10 *)

Formula

A054845(a(n)) = 3. - Ray Chandler, Sep 20 2023

A054999 Integers that can be expressed as the sum of consecutive primes in exactly 4 ways.

Original entry on oeis.org

1151, 1164, 1320, 1367, 1650, 1854, 1951, 2393, 2647, 2689, 2856, 2867, 3198, 3264, 3389, 3754, 4200, 4920, 4957, 5059, 5100, 5153, 5770, 5999, 6504, 7451, 7901, 8152, 8819, 10134, 10320, 10499, 10536, 10649, 10859, 10949, 11058, 12294
Offset: 1

Views

Author

Jud McCranie, May 30 2000

Keywords

References

  • R. K. Guy, Unsolved Problems in Number Theory, section C2.

Crossrefs

Formula

A054845(a(n)) = 4. - Ray Chandler, Sep 20 2023

A054997 Integers that can be expressed as the sum of consecutive primes in exactly 2 ways.

Original entry on oeis.org

5, 17, 23, 31, 36, 53, 59, 60, 67, 71, 72, 90, 97, 100, 101, 109, 112, 119, 120, 127, 131, 138, 139, 143, 152, 173, 180, 181, 187, 204, 210, 211, 221, 228, 233, 258, 263, 269, 271, 276, 300, 304, 323, 330, 331, 349, 353, 372, 373, 379, 384, 390, 395, 408
Offset: 1

Views

Author

Jud McCranie, May 30 2000

Keywords

Examples

			5 can be expressed as 5 or 2+3, so 5 is in the sequence.
		

References

  • R. K. Guy, Unsolved Problems in Number Theory, section C2.

Crossrefs

Formula

A054845(a(n)) = 2. - Ray Chandler, Sep 20 2023

A334007 a(n) is the least integer that can be expressed as the sum of one or more consecutive nonzero triangular numbers in exactly n ways.

Original entry on oeis.org

1, 10, 2180, 10053736, 13291443468940
Offset: 1

Views

Author

Ilya Gutkovskiy, Apr 12 2020

Keywords

Examples

			Let S(k, m) denote the sum of m triangular numbers starting from k(k+1)/2. We have
a(1) = S(1, 1);
a(2) = S(4, 1) = S(1, 3);
a(3) = S(31, 4) = S(27, 5) = S(9, 15);
a(4) = S(945, 22) = S(571, 56) = S(968, 21) = S(131, 266);
a(5) = S(4109, 38947) = S(25213, 20540) = S(10296, 32943) = S(32801, 15834) = S(31654, 16472).
		

Crossrefs

Extensions

a(5) from Giovanni Resta, Apr 13 2020

A334012 a(n) is the least integer that can be expressed as the sum of one or more consecutive nonzero octagonal numbers in exactly n ways.

Original entry on oeis.org

1, 1045, 5985
Offset: 1

Views

Author

Ilya Gutkovskiy, Apr 12 2020

Keywords

Examples

			From _Seiichi Manyama_, May 16 2021: (Start)
Let S(k, m) denote the sum of m octagonal numbers starting from k*(3*k-2). We have
a(1) = S(1, 1);
a(2) = S(19, 1) = S(1, 10);
a(3) = S(45, 1) = S(11, 9) = S(1, 18). (End)
		

Crossrefs

A055001 Integers that can be expressed as the sum of consecutive primes in exactly 6 ways.

Original entry on oeis.org

34421, 130638, 229841, 235493, 271919, 295504, 345011, 347856, 358446, 358877, 414221, 429804, 434669, 480951, 488603, 532423, 532823, 543625, 561375, 621937, 626852, 655561, 687496, 703087, 734069, 746829, 810418, 824099, 888793
Offset: 1

Views

Author

Jud McCranie, May 30 2000

Keywords

References

  • R. K. Guy, Unsolved Problems in Number Theory, section C2.

Crossrefs

Formula

A054845(a(n)) = 6. - Ray Chandler, Sep 20 2023

A334008 a(n) is the least integer that can be expressed as the sum of one or more consecutive nonzero pentagonal numbers in exactly n ways.

Original entry on oeis.org

1, 287, 472320, 89051435880
Offset: 1

Views

Author

Ilya Gutkovskiy, Apr 12 2020

Keywords

Examples

			Let S(k, m) denote the sum of m pentagonal numbers starting from the k-th. We have
a(1) = S(1, 1);
a(2) = S(14, 1) = S(2, 7);
a(3) = S(103, 24) = S(19, 80) = S(67, 41);
a(4) = S(10833, 484) = S(4542, 1936) = S(9153, 660) = S(2817, 3036);
		

Crossrefs

Extensions

a(4) from Giovanni Resta, Apr 13 2020
Showing 1-10 of 22 results. Next