%I
%S 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,
%T 22,2,10,24,18,26,20,27,24,6,8,14,30,24,28,30,29,28,2,18,20,18,32,28,
%U 34,32,39,34,6,8,20,26,22,34,38,48,36,41,38,14,12,18,22,30
%N a(n) = prime(n)  Sum_{k=1..A002024(n)1} a(nk), where A002024(m) = [sqrt(2*m)+1/2] is "n appears n times".
%C Form this sequence into a number triangle, then it seems that:
%C (1) the odd numbers only appear adjacent to the main diagonal;
%C (2) the number 2 only appears in column 1.
%H Paul D. Hanna, <a href="/A217916/b217916.txt">Table of n, a(n) for n = 1..10011</a>
%F Row sums equal A011756(n) = prime(n(n+1)/2).
%e Start with a(1) = 2, from then on, the sum of A002024(n) consecutive terms prior to and including a(n) generates the nth prime number
%e (A002024 begins: [1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, ...]).
%e n=1: 2 = 2; (start)
%e n=2: 3 = 2 + 1; (sum of 2 terms = prime)
%e n=3: 5 = 1 + 4; "
%e n=4: 7 = 1 + 4 + 2; (sum of 3 terms = prime)
%e n=5: 11 = 4 + 2 + 5; "
%e n=6: 13 = 2 + 5 + 6; "
%e n=7: 17 = 2 + 5 + 6 + 4; (sum of 4 terms = prime)
%e n=8: 19 = 5 + 6 + 4 + 4; "
%e n=9: 23 = 6 + 4 + 4 + 9; "
%e n=10: 29 = 4 + 4 + 9 + 12; "
%e n=11: 31 = 4 + 4 + 9 + 12 + 2; (sum of 5 terms = prime)
%e ...
%e As a triangle, the sequence begins:
%e 2;
%e 1, 4;
%e 2, 5, 6;
%e 4, 4, 9, 12;
%e 2, 10, 8, 11, 16;
%e 6, 8, 12, 14, 15, 18;
%e 6, 10, 14, 20, 18, 17, 22;
%e 2, 10, 24, 18, 26, 20, 27, 24;
%e 6, 8, 14, 30, 24, 28, 30, 29, 28;
%e 2, 18, 20, 18, 32, 28, 34, 32, 39, 34;
%e 6, 8, 20, 26, 22, 34, 38, 48, 36, 41, 38;
%e 14, 12, 18, 22, 30, 28, 42, 44, 54, 40, 47, 46;
%e 4, 22, 22, 20, 32, 32, 34, 46, 50, 62, 44, 49, 50;
%e 12, 12, 26, 30, 24, 38, 44, 36, 64, 56, 72, 50, 55, 52;
%e 6, 22, 18, 32, 32, 30, 44, 48, 38, 76, 66, 74, 54, 61, 58;
%e 2, 18, 26, 24, 40, 42, 38, 54, 56, 44, 82, 70, 82, 60, 65, 66;
%e 4, 16, 28, 38, 26, 50, 44, 42, 56, 66, 58, 86, 72, 86, 74, 69, 68;
%e 4, 24, 20, 36, 48, 34, 54, 50, 48, 70, 70, 64, 92, 80, 92, 86, 73, 74;
%e 2, 14, 26, 26, 46, 50, 44, 56, 56, 66, 74, 72, 68, 98, 86, 100, 92, 79, 96;
%e 2, 12, 22, 36, 32, 52, 58, 56, 60, 62, 72, 76, 78, 80, 108, 104, 102, 96, 85, 98; ...
%e Notice the positions of the odd numbers and of the number 2;
%e the only odd numbers appear adjacent to the main diagonal and
%e the number 2 only appears in the first column.
%o (PARI) /* Using the recurrence (slow) */
%o {a(n)=if(n<1,0,if(n==1,2,prime(n)sum(k=1,floor(1/2+sqrt(2*n))1,a(nk))))}
%o for(n=1,120,print1(a(n),", "))
%o (PARI) /* Print as a Triangle of M Rows (much faster) */
%o {M=20;A=vector(M*(M+1)/2);}
%o {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[nk])))}
%o for(n=1,M,for(k=1,n,print1(a(n*(n1)/2+k),", "));print(""))
%Y Cf. A011756, A217917 (odd numbers that appear), A217918 (positions of 2), A217919 (rows in which 2 appears), A217920 (column 1).
%K nonn
%O 1,1
%A _Paul D. Hanna_, Mar 04 2013
