login
a(n) = n*(n + 1)/2 - pi(n), where pi(n) = A000720(n) is the prime counting function.
4

%I #43 Sep 08 2022 08:46:12

%S 1,2,4,8,12,18,24,32,41,51,61,73,85,99,114,130,146,164,182,202,223,

%T 245,267,291,316,342,369,397,425,455,485,517,550,584,619,655,691,729,

%U 768,808,848,890,932,976,1021,1067,1113,1161,1210,1260,1311,1363,1415,1469,1524

%N a(n) = n*(n + 1)/2 - pi(n), where pi(n) = A000720(n) is the prime counting function.

%C Number of lattice points (x,y) in the region 1 <= x <= n, 1 <= y <= n - A010051(n); see example.

%C This sequence gives the row sums of the triangle A257232. - _Wolfdieter Lang_, Apr 21 2015

%H Reinhard Zumkeller, <a href="/A256885/b256885.txt">Table of n, a(n) for n = 1..10000</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PrimeCountingFunction.html">Prime Counting Function</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Prime-counting_function">Prime-counting function</a>

%F a(n) = A000217(n) - A000720(n).

%F a(n) - a(n-1) = A014684(n), n >= 2.

%F a(n) = Sum_{i=1..n} A014684(i).

%F a(n) = 1 + Sum_{i=2..n}(i - A000720(i) + A000720(i-1)).

%e 10 . x

%e 9 . x x

%e 8 . x x x

%e 7 . . x x x

%e 6 . x x x x x

%e 5 . . x x x x x

%e 4 . x x x x x x x

%e 3 . . x x x x x x x

%e 2 . . x x x x x x x x

%e 1 . x x x x x x x x x x

%e 0 .__.__.__.__.__.__.__.__.__.__.

%e 0 1 2 3 4 5 6 7 8 9 10

%p with(numtheory)[pi]: A256885:=n->n*(n+1)/2-pi(n): seq(A256885(n), n=1..100);

%t Table[n (n + 1)/2 - PrimePi[n], {n, 1, 50}]

%o (Magma) [n*(n + 1)/2 - #PrimesUpTo(n): n in [1..60] ]; // _Vincenzo Librandi_, Apr 12 2015

%o (PARI) vector(80, n, n*(n+1)/2 - primepi(n)) \\ _Michel Marcus_, Apr 13 2015

%o (Haskell)

%o a256885 n = a000217 n - a000720 n -- _Reinhard Zumkeller_, Apr 21 2015

%Y Cf. A000217, A000720, A010051, A014684, A113638, A257232.

%K nonn,easy

%O 1,2

%A _Wesley Ivan Hurt_, Apr 11 2015

%E Edited, following the hint by Reinhard Zumkeller to change the offset. - _Wolfdieter Lang_, Apr 22 2015