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.

A217916 a(n) = prime(n) - Sum_{k=1..A002024(n)-1} a(n-k), where A002024(m) = [sqrt(2*m)+1/2] is "n appears n times".

Original entry on oeis.org

2, 1, 4, 2, 5, 6, 4, 4, 9, 12, 2, 10, 8, 11, 16, 6, 8, 12, 14, 15, 18, 6, 10, 14, 20, 18, 17, 22, 2, 10, 24, 18, 26, 20, 27, 24, 6, 8, 14, 30, 24, 28, 30, 29, 28, 2, 18, 20, 18, 32, 28, 34, 32, 39, 34, 6, 8, 20, 26, 22, 34, 38, 48, 36, 41, 38, 14, 12, 18, 22, 30
Offset: 1

Views

Author

Paul D. Hanna, Mar 04 2013

Keywords

Comments

Form this sequence into a number triangle, then it seems that:
(1) the odd numbers only appear adjacent to the main diagonal;
(2) the number 2 only appears in column 1.

Examples

			Start with a(1) = 2, from then on, the sum of A002024(n) consecutive terms prior to and including a(n) generates the n-th prime number
(A002024 begins: [1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, ...]).
n=1: 2 = 2; (start)
n=2: 3 = 2 + 1; (sum of 2 terms = prime)
n=3: 5 = 1 + 4;     "
n=4: 7 = 1 + 4 + 2; (sum of 3 terms = prime)
n=5: 11 = 4 + 2 + 5;    "
n=6: 13 = 2 + 5 + 6;    "
n=7: 17 = 2 + 5 + 6 + 4; (sum of 4 terms = prime)
n=8: 19 = 5 + 6 + 4 + 4;    "
n=9: 23 = 6 + 4 + 4 + 9;    "
n=10: 29 = 4 + 4 + 9 + 12;    "
n=11: 31 = 4 + 4 + 9 + 12 + 2; (sum of 5 terms = prime)
...
As a triangle, the sequence begins:
2;
1, 4;
2, 5, 6;
4, 4, 9, 12;
2, 10, 8, 11, 16;
6, 8, 12, 14, 15, 18;
6, 10, 14, 20, 18, 17, 22;
2, 10, 24, 18, 26, 20, 27, 24;
6, 8, 14, 30, 24, 28, 30, 29, 28;
2, 18, 20, 18, 32, 28, 34, 32, 39, 34;
6, 8, 20, 26, 22, 34, 38, 48, 36, 41, 38;
14, 12, 18, 22, 30, 28, 42, 44, 54, 40, 47, 46;
4, 22, 22, 20, 32, 32, 34, 46, 50, 62, 44, 49, 50;
12, 12, 26, 30, 24, 38, 44, 36, 64, 56, 72, 50, 55, 52;
6, 22, 18, 32, 32, 30, 44, 48, 38, 76, 66, 74, 54, 61, 58;
2, 18, 26, 24, 40, 42, 38, 54, 56, 44, 82, 70, 82, 60, 65, 66;
4, 16, 28, 38, 26, 50, 44, 42, 56, 66, 58, 86, 72, 86, 74, 69, 68;
4, 24, 20, 36, 48, 34, 54, 50, 48, 70, 70, 64, 92, 80, 92, 86, 73, 74;
2, 14, 26, 26, 46, 50, 44, 56, 56, 66, 74, 72, 68, 98, 86, 100, 92, 79, 96;
2, 12, 22, 36, 32, 52, 58, 56, 60, 62, 72, 76, 78, 80, 108, 104, 102, 96, 85, 98; ...
Notice the positions of the odd numbers and of the number 2;
the only odd numbers appear adjacent to the main diagonal and
the number 2 only appears in the first column.
		

Crossrefs

Cf. A011756, A217917 (odd numbers that appear), A217918 (positions of 2), A217919 (rows in which 2 appears), A217920 (column 1).

Programs

  • PARI
    /* Using the recurrence (slow) */
    {a(n)=if(n<1,0,if(n==1,2,prime(n)-sum(k=1,floor(1/2+sqrt(2*n))-1,a(n-k))))}
    for(n=1,120,print1(a(n),", "))
    
  • PARI
    /* Print as a Triangle of M Rows (much faster) */
    {M=20;A=vector(M*(M+1)/2);}
    {a(n)=A[n]=if(n<1,0,if(n==1,2,prime(n)-sum(k=1,floor(1/2+sqrt(2*n))-1,A[n-k])))}
    for(n=1,M,for(k=1,n,print1(a(n*(n-1)/2+k),", "));print(""))

Formula

Row sums equal A011756(n) = prime(n(n+1)/2).