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

A007504 Sum of the first n primes.

Original entry on oeis.org

0, 2, 5, 10, 17, 28, 41, 58, 77, 100, 129, 160, 197, 238, 281, 328, 381, 440, 501, 568, 639, 712, 791, 874, 963, 1060, 1161, 1264, 1371, 1480, 1593, 1720, 1851, 1988, 2127, 2276, 2427, 2584, 2747, 2914, 3087, 3266, 3447, 3638, 3831, 4028, 4227, 4438, 4661, 4888
Offset: 0

Views

Author

Keywords

Comments

It appears that a(n)^2 - a(n-1)^2 = A034960(n). - Gary Detlefs, Dec 20 2011
This is true. Proof: By definition we have A034960(n) = Sum_{k = (a(n-1)+1)..a(n)} (2*k-1). Since Sum_{k = 1..n} (2*k-1) = n^2, it follows A034960(n) = a(n)^2 - a(n-1)^2, for n > 1. - Hieronymus Fischer, Sep 27 2012 [formulas above adjusted to changed offset of A034960 - Hieronymus Fischer, Oct 14 2012]
Row sums of the triangle in A037126. - Reinhard Zumkeller, Oct 01 2012
Ramanujan noticed the apparent identity between the prime parts partition numbers A000607 and the expansion of Sum_{k >= 0} x^a(k)/((1-x)...(1-x^k)), cf. A046676. See A192541 for the difference between the two. - M. F. Hasler, Mar 05 2014
For n > 0: row 1 in A254858. - Reinhard Zumkeller, Feb 08 2015
a(n) is the smallest number that can be partitioned into n distinct primes. - Alonso del Arte, May 30 2017
For a(n) < m < a(n+1), n > 0, at least one m is a perfect square.
Proof: For n = 1, 2, ..., 6, the proposition is clear. For n > 6, a(n) < ((prime(n) - 1)/2)^2, set (k - 1)^2 <= a(n) < k^2 < ((prime(n) + 1)/2)^2, then k^2 < (k - 1)^2 + prime(n) <= a(n) + prime(n) = a(n+1), so m = k^2 is this perfect square. - Jinyuan Wang, Oct 04 2018
For n >= 5 we have a(n) < ((prime(n)+1)/2)^2. This can be shown by noting that ((prime(n)+1)/2)^2 - ((prime(n-1)+1)/2)^2 - prime(n) = (prime(n)+prime(n-1))*(prime(n)-prime(n-1)-2)/4 >= 0. - Jianing Song, Nov 13 2022
Washington gives an oscillation formula for |a(n) - pi(n^2)|, see links. - Charles R Greathouse IV, Dec 07 2022

References

  • E. Bach and J. Shallit, §2.7 in Algorithmic Number Theory, Vol. 1: Efficient Algorithms, MIT Press, Cambridge, MA, 1996.
  • H. L. Nelson, "Prime Sums", J. Rec. Math., 14 (1981), 205-206.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

See A122989 for the value of Sum_{n >= 1} 1/a(n).

Programs

  • GAP
    P:=Filtered([1..250],IsPrime);;
    a:=Concatenation([0],List([1..Length(P)],i->Sum([1..i],k->P[k]))); # Muniru A Asiru, Oct 07 2018
    
  • Haskell
    a007504 n = a007504_list !! n
    a007504_list = scanl (+) 0 a000040_list
    -- Reinhard Zumkeller, Oct 01 2014, Oct 03 2011
    
  • Magma
    [0] cat [&+[ NthPrime(k): k in [1..n]]: n in [1..50]]; // Bruno Berselli, Apr 11 2011 (adapted by Vincenzo Librandi, Nov 27 2015 after Hasler's change on Mar 05 2014)
    
  • Maple
    s1:=[2]; for n from 2 to 1000 do s1:=[op(s1),s1[n-1]+ithprime(n)]; od: s1;
    A007504 := proc(n)
        add(ithprime(i), i=1..n) ;
    end proc: # R. J. Mathar, Sep 20 2015
  • Mathematica
    Accumulate[Prime[Range[100]]] (* Zak Seidov, Apr 10 2011 *)
    primeRunSum = 0; Table[primeRunSum = primeRunSum + Prime[k], {k, 100}] (* Zak Seidov, Apr 16 2011 *)
  • PARI
    A007504(n) = sum(k=1,n,prime(k)) \\ Michael B. Porter, Feb 26 2010
    
  • PARI
    a(n) = vecsum(primes(n)); \\ Michel Marcus, Feb 06 2021
    
  • Python
    from itertools import accumulate, count, islice
    from sympy import prime
    def A007504_gen(): return accumulate(prime(n) if n > 0 else 0 for n in count(0))
    A007504_list = list(islice(A007504_gen(),20)) # Chai Wah Wu, Feb 23 2022

Formula

a(n) ~ n^2 * log(n) / 2. - Ahmed Fares (ahmedfares(AT)my-deja.com), Apr 24 2001 (see Bach & Shallit 1996)
a(n) = A014284(n+1) - 1. - Jaroslav Krizek, Aug 19 2009
a(n+1) - a(n) = A000040(n+1). - Jaroslav Krizek, Aug 19 2009
a(A051838(n)) = A002110(A051838(n)) / A116536(n). - Reinhard Zumkeller, Oct 03 2011
a(n) = min(A068873(n), A073619(n)) for n > 1. - Jonathan Sondow, Jul 10 2012
a(n) = A033286(n) - A152535(n). - Omar E. Pol, Aug 09 2012
For n >= 3, a(n) >= (n-1)^2 * (log(n-1) - 1/2)/2 and a(n) <= n*(n+1)*(log(n) + log(log(n))+ 1)/2. Thus a(n) = n^2 * log(n) / 2 + O(n^2*log(log(n))). It is more precise than in Fares's comment. - Vladimir Shevelev, Aug 01 2013
a(n) = (n^2/2)*(log n + log log n - 3/2 + (log log n - 3)/log n + (2 (log log n)^2 - 14 log log n + 27)/(4 log^2 n) + O((log log n/log n)^3)) [Sinha]. - Charles R Greathouse IV, Jun 11 2015
G.f: (x*b(x))/(1-x), where b(x) is the g.f. of A000040. - Mario C. Enriquez, Dec 10 2016
a(n) = A008472(A002110(n)), for n > 0. - Michel Marcus, Jul 16 2020

Extensions

More terms from Stefan Steinerberger, Apr 11 2006
a(0) = 0 prepended by M. F. Hasler, Mar 05 2014

A104887 Triangle T(n,k) = (n-k+1)-th prime, read by rows.

Original entry on oeis.org

2, 3, 2, 5, 3, 2, 7, 5, 3, 2, 11, 7, 5, 3, 2, 13, 11, 7, 5, 3, 2, 17, 13, 11, 7, 5, 3, 2, 19, 17, 13, 11, 7, 5, 3, 2, 23, 19, 17, 13, 11, 7, 5, 3, 2, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 41, 37, 31, 29
Offset: 1

Views

Author

Gary W. Adamson, Mar 29 2005

Keywords

Comments

Repeatedly writing the prime sequence backwards.
Sequence B is called a reverse reluctant sequence of sequence A, if B is triangle array read by rows: row number k lists first k elements of the sequence A in reverse order. Sequence A104887 is the reverse reluctant sequence of sequence the prime numbers (A000040). - Boris Putievskiy, Dec 13 2012

Examples

			Triangle begins:
   2;
   3,  2;
   5,  3,  2;
   7,  5,  3,  2;
  11,  7,  5,  3,  2;
  13, 11,  7,  5,  3,  2;
  17, 13, 11,  7,  5,  3,  2;
		

Crossrefs

Reflected triangle of A037126.
Cf. A098012 (partial products per row).

Programs

  • GAP
    P:=Filtered([1..200],IsPrime);;
    T:=Flat(List([1..13],n->List([1..n],k->P[n-k+1]))); # Muniru A Asiru, Mar 16 2019
  • Haskell
    import Data.List (inits)
    a104887 n k = a104887_tabl !! (n-1) !! (k-1)
    a104887_row n = a104887_tabl !! (n-1)
    a104887_tabl = map reverse $ tail $ inits a000040_list
    -- Reinhard Zumkeller, Oct 02 2014
    
  • Maple
    T:=(n,k)->ithprime(n-k+1): seq(seq(T(n,k),k=1..n),n=1..13); # Muniru A Asiru, Mar 16 2019
  • Mathematica
    Module[{nn=15,prms},prms=Prime[Range[nn]];Table[Reverse[Take[prms,n]],{n,nn}]]//Flatten (* Harvey P. Dale, Aug 10 2021 *)

Formula

T(n,k) = A000040(n-k+1); a(n) = A000040(A004736(n)).
a(n) = A000040(m), where m=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2). - Boris Putievskiy, Dec 13 2012

Extensions

Edited by Ralf Stephan, Apr 05 2009

A220280 The reluctant sequence for A002260.

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 3, 1, 1, 2, 1, 2, 3, 1, 1, 1, 2, 1, 2, 3, 1, 2, 1, 1, 2, 1, 2, 3, 1, 2, 3, 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3
Offset: 1

Views

Author

Boris Putievskiy, Dec 12 2012

Keywords

Comments

The reluctant sequence B for a sequence A is a triangular array in which row k (>= 1) consists of the first k terms of A.
Here A002260 is the reluctant sequence for the sequence 1,2,3,... of positive numbers (A000027).

Examples

			A002260 begins
  1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, ...
so the first few rows of the new triangle are
   1,
   1, 1,
   1, 1, 2,
   1, 1, 2, 1,
   1, 1, 2, 1, 2,
   1, 1, 2, 1, 2, 3,
   ...
                                                                               ~
		

Crossrefs

Programs

  • Python
    t=int((math.sqrt(8*n-7) - 1)/ 2)
    n1=n-t*(t+1)/2
    t1=int((math.sqrt(8*n1-7) - 1)/ 2)
    a=n1-t1*(t1+1)/2

Formula

a(n) = n1 - t1(t1+1)/2, where n1 = n - t(t+1)/2, t1 = floor[(-1+sqrt(8*n1-7))/2], t=floor[(-1+sqrt(8*n-7))/2]. For example, a(6)=2 since t=2, t1=1, n1=3.

Extensions

Edited by N. J. A. Sloane, Jun 07 2024

A109400 For all k: the first k numbers followed by the first k primes.

Original entry on oeis.org

1, 2, 1, 2, 2, 3, 1, 2, 3, 2, 3, 5, 1, 2, 3, 4, 2, 3, 5, 7, 1, 2, 3, 4, 5, 2, 3, 5, 7, 11, 1, 2, 3, 4, 5, 6, 2, 3, 5, 7, 11, 13, 1, 2, 3, 4, 5, 6, 7, 2, 3, 5, 7, 11, 13, 17, 1, 2, 3, 4, 5, 6, 7, 8, 2, 3, 5, 7, 11, 13, 17, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 5, 7, 11, 13, 17, 19, 23
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 27 2005

Keywords

Comments

a(k*(k-1) + m) = a(A002378(k-1) + m) = m for 1<=m<=k;
a(k^2 + m) = a(A000290(k) + m) = A000040(m) for 1<=m<=k;
see A109401 for number of primes and A109402 for partial sums.

Examples

			1, 2; 1 2, 2 3; 1 2 3, 2 3 5; 1 2 3 4, 2 3 5 7; 1 2 ...
		

Crossrefs

Programs

  • Haskell
    a109400 n = a109400_list !! (n-1)
    a109400_list = concat $ zipWith (++) a002260_tabl a037126_tabl
    -- Reinhard Zumkeller, Jun 23 2015, Dec 11 2011
  • Mathematica
    With[{prs=Prime[Range[20]]},Flatten[Table[{Range[n],Take[prs,n]},{n,10}]]] (* Harvey P. Dale, Dec 08 2011 *)

A138143 Triangle read by rows in which row n lists p(1), p(2), ..., p(n), p(n-1), ..., p(1), where p(i) = i-th prime.

Original entry on oeis.org

2, 2, 3, 2, 2, 3, 5, 3, 2, 2, 3, 5, 7, 5, 3, 2, 2, 3, 5, 7, 11, 7, 5, 3, 2, 2, 3, 5, 7, 11, 13, 11, 7, 5, 3, 2, 2, 3, 5, 7, 11, 13, 17, 13, 11, 7, 5, 3, 2, 2, 3, 5, 7, 11, 13, 17, 19, 17, 13, 11, 7, 5, 3, 2, 2, 3, 5, 7, 11, 13, 17, 19, 23, 19, 17, 13, 11, 7, 5, 3, 2, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2
Offset: 1

Views

Author

Omar E. Pol, Mar 09 2008

Keywords

Comments

Row n contains 2n-1 terms and each column lists the prime numbers A000040.
Triangle of primes mentioned in A061802.

Examples

			Triangle begins:
.............. 2
........... 2, 3, 2
........ 2, 3, 5, 3, 2
..... 2, 3, 5, 7, 5, 3, 2
.. 2, 3, 5, 7,11, 7, 5, 3, 2
		

Crossrefs

Programs

  • Mathematica
    nn=10;Module[{pr=Prime[Range[nn]],e},Flatten[Table[e=Take[pr,n];Join[ e,Reverse[Most[e]]],{n,nn}]]] (* Harvey P. Dale, Mar 14 2015 *)

Extensions

Edited by N. J. A. Sloane, Apr 07 2008, Nov 15 2008

A264662 Triangle read by rows: row n contains the first n primes in lexicographical order of their mirrored binary representation.

Original entry on oeis.org

2, 2, 3, 2, 5, 3, 2, 5, 3, 7, 2, 5, 3, 11, 7, 2, 5, 13, 3, 11, 7, 2, 17, 5, 13, 3, 11, 7, 2, 17, 5, 13, 3, 19, 11, 7, 2, 17, 5, 13, 3, 19, 11, 7, 23, 2, 17, 5, 13, 29, 3, 19, 11, 7, 23, 2, 17, 5, 13, 29, 3, 19, 11, 7, 23, 31, 2, 17, 5, 37, 13, 29, 3, 19, 11
Offset: 1

Views

Author

Reinhard Zumkeller, Nov 20 2015

Keywords

Comments

T(n,A263856(n)) = A000040(n): A263856(n) = index of prime(n) in n-th row.

Examples

			.   n |   T(n,k), k=1..n
. ----+-----------------------------------------------------------------
.   1 | 2                          01
.   2 | 2  3                       01 11
.   3 | 2  5  3                    01 101   11
.   4 | 2  5  3  7                 01 101   11   111
.   5 | 2  5  3 11  7              01 101   11   1101 111
.   6 | 2  5 13  3 11  7           01 101   1011 11   1101 111
.   7 | 2 17  5 13  3 11  7        01 10001 101  1011 11   1101  111
.   8 | 2 17  5 13  3 19 11  7     01 10001 101  1011 11   11001 1101 111
.   9 | 2 17  5 13  3 19 11  7 23
.  10 | 2 17  5 13 29  3 19 11  7 23
.  11 | 2 17  5 13 29  3 19 11  7 23 31
.  12 | 2 17  5 37 13 29  3 19 11  7 23 31
.  13 | 2 17 41  5 37 13 29  3 19 11  7 23 31
.  14 | 2 17 41  5 37 13 29  3 19 11 43 7  23 31
.  15 | 2 17 41  5 37 13 29  3 19 11 43  7 23 47 31
.  16 | 2 17 41  5 37 53 13 29  3 19 11 43  7 23 47 31
.  17 | 2 17 41  5 37 53 13 29  3 19 11 43 59  7 23 47 31
.  18 | 2 17 41  5 37 53 13 29 61  3 19 11 43 59  7 23 47 31
.  19 | 2 17 41  5 37 53 13 29 61  3 67 19 11 43 59  7 23 47 31
.  20 | 2 17 41  5 37 53 13 29 61  3 67 19 11 43 59  7 71 23 47 31
		

Crossrefs

Cf. A263846, A000040, A007088, A007504 (row sums), A264666 (partial row products), A037126 (rows sorted naturally).

Programs

  • Haskell
    import Data.List (inits, sortBy); import Data.Function (on)
    a264662 n k = a264662_tabl !! (n-1) !! (n-1)
    a264662_row n = a264662_tabl !! (n-1)
    a264662_tabl = map (sortBy (compare `on` (reverse . show . a007088))) $
                       tail $ inits a000040_list
  • Mathematica
    row[n_] := SortBy[Prime[Range[n]], StringJoin[ToString /@ Reverse[IntegerDigits[#, 2]]]&];
    Table[row[n], {n, 1, 20}] // Flatten (* Jean-François Alcover, Sep 25 2021 *)

A332644 Largest of the least integers of prime signatures over all partitions of n into distinct parts.

Original entry on oeis.org

1, 2, 4, 12, 24, 72, 360, 720, 2160, 10800, 75600, 151200, 453600, 2268000, 15876000, 174636000, 349272000, 1047816000, 5239080000, 36673560000, 403409160000, 5244319080000, 10488638160000, 31465914480000, 157329572400000, 1101307006800000, 12114377074800000
Offset: 0

Views

Author

Alois P. Heinz, Feb 18 2020

Keywords

Crossrefs

Programs

  • Maple
    b:= proc(n, i, j) option remember;
          `if`(i*(i+1)/2 b(n$2, 1):
    seq(a(n), n=0..30);
    # second Maple program:
    a:= proc(n) option remember; `if`(n=0, 1, a(n-1)*
          ithprime(n-(t-> t*(t+1)/2)(floor((sqrt(8*n-7)-1)/2))))
        end:
    seq(a(n), n=0..30);
  • Mathematica
    b[n_, i_, j_] := b[n, i, j] = If[i(i+1)/2 < n, 0, If[n == 0, 1, Max[b[n, i - 1, j], Prime[j]^i b[n - i, Min[n - i, i - 1], j + 1]]]];
    a[n_] := b[n, n, 1];
    a /@ Range[0, 30] (* Jean-François Alcover, May 07 2020, after 1st Maple program *)

Formula

a(n) = A328524(n,A000009(n)).
A001221(a(n)) = A003056(n).
A001222(a(n)) = n.
A046523(a(n)) = a(n).
a(n)/a(n-1) = A037126(n) = A000040(n-A000217(A003056(n))) for n > 0.
a(n) in { A025487 }.
a(n) in { A055932 }.
a(n) in { A087980 }.
A007814(a(n)) = A123578(n).

A138117 Triangle read by rows: row n lists the first 2n-1 prime numbers.

Original entry on oeis.org

2, 2, 3, 5, 2, 3, 5, 7, 11, 2, 3, 5, 7, 11, 13, 17, 2, 3, 5, 7, 11, 13, 17, 19, 23, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47
Offset: 1

Views

Author

Omar E. Pol, Mar 14 2008, corrected Mar 15 2008

Keywords

Examples

			Triangle begins:
....... 2
..... 2,3,5
... 2,3,5,7,11
. 2,3,5,7,11,13,17
		

Crossrefs

Programs

  • Mathematica
    nn=10;Flatten[Table[Take[Prime[Range[2nn+1]],2n+1],{n,0,nn}]] (* Harvey P. Dale, Aug 16 2011 *)

A354271 Irregular array of the prime numbers read by rows.

Original entry on oeis.org

2, 3, 2, 5, 7, 3, 11, 2, 5, 13, 17, 3, 11, 19, 2, 7, 23, 17, 29, 5, 13, 31, 7, 37, 3, 11, 19, 29, 41, 2, 5, 13, 43, 17, 47, 3, 11, 23, 41, 53, 2, 7, 37, 59, 31, 61, 5, 13, 23, 43, 67, 7, 19, 29, 37, 59, 71, 3, 11, 41, 73, 2, 5, 17, 47, 79, 19, 31, 53, 71, 83, 3, 67
Offset: 1

Views

Author

Tamas Sandor Nagy, May 22 2022

Keywords

Comments

The construction of the array is made in an orthogonal grid with columns and rows.
Along the sloping upper boundary of the array are written the guiding prime numbers, each in a column of its value and in a row of its index. From these leading entries, on downward and leftward running antidiagonal lines the preceding primes are entered. In reverse order and with the due prime gaps, these will fall into the columns of their own value, below the guiding primes on top.
The antidiagonals are the same as the rows of the triangle in A037126.
The rows that begin with 2's end with A256491.
Row n lists all primes of the form A000040(n - k) - k for positive k. - Thomas Scheuerle, May 23 2022

Examples

			.  2
.  .  3
.  2  .  .  5
.  .  .  .  .  .  7
.  .  3  .  .  .  .  .  .  . 11
.  2  .  .  5  .  .  .  .  .  .  . 13
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . 17
.  .  3  .  .  .  .  .  .  . 11  .  .  .  .  .  .  . 19
.  2  .  .  .  .  7  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . 23
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . 17  .  .  .  .  .  .
.  .  .  .  5  .  .  .  .  .  .  . 13  .  .  .  .  .  .  .  .  .  .
.  .  .  .  .  .  7  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
.  .  3  .  .  .  .  .  .  . 11  .  .  .  .  .  .  . 19  .  .  .  .
.  2  .  .  5  .  .  .  .  .  .  . 13  .  .  .  .  .  .  .  .  .  .
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . 17  .  .  .  .  .  .
.  .  3  .  .  .  .  .  .  . 11  .  .  .  .  .  .  .  .  .  .  . 23
.  2  .  .  .  .  7  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
		

Crossrefs

Programs

  • MATLAB
    function a = A354271( max_row )
        p = primes(max_row*floor(2*max_row*log(max_row)));
        a = [];
        for r = 1:max_row
            row = p(1:r)-(r-1:-1:0);
            row = row(isprime(max(row,0)) > 0);
            a = [a row];
        end
    end % Thomas Scheuerle, May 23 2022
  • Mathematica
    Table[Select[Array[Prime[#] - (n - #) &, n], And[# > 0, PrimeQ[#]] &], {n, 24}] // Flatten (* Michael De Vlieger, May 25 2022 *)
    (* Extract data from the bitmap: set k to number of rows desired, up to 1024 *)
    k = 120; Map[Prime /@ Position[#, 0.][[All, 1]] &, ImageData[Import["https://oeis.org/A354271/a354271_2.png"]][[1 ;; k]] ] // Flatten (* Michael De Vlieger, May 25 2022 *)
Showing 1-9 of 9 results.