A282516
Number T(n,k) of k-element subsets of [n] having a prime element sum; triangle T(n,k), n>=0, 0<=k<=n, read by rows.
Original entry on oeis.org
0, 0, 0, 0, 1, 1, 0, 2, 2, 0, 0, 2, 4, 1, 0, 0, 3, 5, 2, 2, 0, 0, 3, 7, 6, 4, 2, 0, 0, 4, 9, 10, 11, 7, 1, 0, 0, 4, 11, 18, 21, 13, 7, 2, 0, 0, 4, 14, 26, 34, 31, 20, 7, 3, 0, 0, 4, 18, 37, 53, 59, 51, 32, 11, 2, 0, 0, 5, 21, 47, 82, 110, 117, 85, 35, 12, 2, 0
Offset: 0
Triangle T(n,k) begins:
0;
0, 0;
0, 1, 1;
0, 2, 2, 0;
0, 2, 4, 1, 0;
0, 3, 5, 2, 2, 0;
0, 3, 7, 6, 4, 2, 0;
0, 4, 9, 10, 11, 7, 1, 0;
0, 4, 11, 18, 21, 13, 7, 2, 0;
0, 4, 14, 26, 34, 31, 20, 7, 3, 0;
0, 4, 18, 37, 53, 59, 51, 32, 11, 2, 0;
0, 5, 21, 47, 82, 110, 117, 85, 35, 12, 2, 0;
...
Columns k=0-10 give:
A000004,
A000720,
A071917,
A320678,
A320679,
A320680,
A320681,
A320682,
A320683,
A320684,
A320685.
First lower diagonal gives
A282518.
-
b:= proc(n, s) option remember; expand(`if`(n=0,
`if`(isprime(s), 1, 0), b(n-1, s)+x*b(n-1, s+n)))
end:
T:= n-> (p-> seq(coeff(p, x, i), i=0..n))(b(n, 0)):
seq(T(n), n=0..16);
-
b[n_, s_] := b[n, s] = Expand[If[n==0, If[PrimeQ[s], 1, 0], b[n-1, s] + x*b[n-1, s+n]]];
T[n_] := Function[p, Table[Coefficient[p, x, i], {i, 0, n}]][b[n, 0]];
Table[T[n], {n, 0, 16}] // Flatten (* Jean-François Alcover, Mar 21 2017, translated from Maple *)
A292918
Let A_n be a square n X n matrix with entries A_n(i,j)=1 if i+j is prime, and A_n(i,j)=0 otherwise. Then a(n) counts the 1's in A_n.
Original entry on oeis.org
1, 3, 5, 9, 11, 15, 19, 23, 29, 37, 43, 51, 57, 63, 71, 81, 89, 97, 105, 113, 123, 135, 145, 157, 169, 181, 195, 209, 221, 235, 249, 263, 277, 293, 309, 327, 345, 363, 381, 401, 419, 439, 457, 475, 495, 515, 533, 551, 571, 591, 613, 637, 659, 683, 709, 735
Offset: 1
|1 1 0 1 0|
|1 0 1 0 1|
A_5 = |0 1 0 1 0| and so a(5) = 11.
|1 0 1 0 0|
|0 1 0 0 0|
-
sol:=[]; for n in [1..56] do k:=0; for i,j in [1..n] do if IsPrime(i+j) then k:=k+1; end if; end for; Append(~sol,k);end for; sol; // Marius A. Burtea, Aug 29 2019
-
with(numtheory):
a:= proc(n) option remember; `if`(n=1, 1,
a(n-1)+2*(pi(2*n-1)-pi(n)))
end:
seq(a(n), n=1..80); # Alois P. Heinz, Sep 29 2017
-
A[n_] := Table[Boole[PrimeQ[i + j]], {i, 1, n}, {j, 1, n}]; a[n_] := Count[Flatten[A[n]], 1];
(* or, after Alois P. Heinz (200 times faster): *)
a[1] = 1; a[n_] := a[n] = a[n-1] + 2(PrimePi[2n-1] - PrimePi[n]);
Array[a, 80] (* Jean-François Alcover, Sep 29 2017 *)
-
first(n) = {my(res = vector(n), pn = 0, p2n1 = 1); res[1] = 1; for(i = 2, n,
if(isprime(i), pn++); if(isprime(2*i-1), p2n1++); res[i] = res[i-1] + 2*(p2n1 - pn)); res} \\ David A. Corneth, Aug 31 2019
-
from sympy import primepi
from sympy.core.cache import cacheit
@cacheit
def a(n): return 1 if n==1 else a(n - 1) + 2*(primepi(2*n - 1) - primepi(n))
print([a(n) for n in range(1, 51)]) # Indranil Ghosh, Dec 13 2017, after Alois P. Heinz
A069879
Number of pairs {i,j} with i different from j; 1<=i<=n; 1<= j <=n such that i+j is a prime number.
Original entry on oeis.org
0, 2, 4, 8, 10, 14, 18, 22, 28, 36, 42, 50, 56, 62, 70, 80, 88, 96, 104, 112, 122, 134, 144, 156, 168, 180, 194, 208, 220, 234, 248, 262, 276, 292, 308, 326, 344, 362, 380, 400, 418, 438, 456, 474, 494, 514, 532, 550, 570, 590, 612, 636, 658, 682, 708, 734
Offset: 1
A140199
a(n) = the number of pairs of (not necessarily distinct) positive integers j and k where j <= n and k <= n such that k+j is prime.
Original entry on oeis.org
1, 2, 3, 5, 6, 8, 10, 12, 15, 19, 22, 26, 29, 32, 36, 41, 45, 49, 53, 57, 62, 68, 73, 79, 85, 91, 98, 105, 111, 118, 125, 132, 139, 147, 155, 164, 173, 182, 191, 201, 210, 220, 229, 238, 248, 258, 267, 276, 286, 296, 307, 319, 330, 342, 355, 368, 382, 396, 409, 422
Offset: 1
For n = 4 there are 5 pairs of positive integers, each <= n=4, that sum to a prime: 1+1=2, 1+2=3, 2+3=5, 1+4=5 and 3+4=7.
Showing 1-4 of 4 results.
Comments