Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #50 Mar 26 2024 05:40:37
%S 0,1,2,0,3,0,4,0,0,0,5,0,6,0,0,0,7,0,8,0,0,0,9,0,0,0,0,0,10,0,11,0,0,
%T 0,0,0,12,0,0,0,13,0,14,0,0,0,15,0,0,0,0,0,16,0,0,0,0,0,17,0,18,0,0,0,
%U 0,0,19,0,0,0,20,0,21,0,0,0,0,0,22,0,0,0,23,0,0,0,0,0,24,0,0,0
%N a(n) = pi(n) if n is prime, otherwise 0.
%C pi(n) is the prime counting function, A000720.
%C Equals row sums of triangle A143541. - _Gary W. Adamson_, Aug 23 2008
%H Reinhard Zumkeller, <a href="/A049084/b049084.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) = pi(n)*(pi(n) - pi(n-1)), pi = A000720. - _Reinhard Zumkeller_, Nov 30 2003
%F a(n) = A000720(n*A010051(n)). - _Labos Elemer_, Jan 09 2004
%F a(n) = A000720(n)*A010051(n). - _R. J. Mathar_, Mar 01 2011
%p A049084 := proc(n)
%p local i;
%p if isprime(n) then
%p for i from 1 do
%p if ithprime(i) = n then
%p return i;
%p end if;
%p end do;
%p else
%p return 0 ;
%p fi;
%p end proc:
%p seq(A049084(n),n=1..120) ;
%t Table[PrimePi[n] * Boole[PrimeQ[n]], {n, 92}] (* _Jean-François Alcover_, Nov 07 2011, after _R. J. Mathar_ *)
%t Table[If[PrimeQ[n],PrimePi[n],0],{n,100}] (* _Harvey P. Dale_, Jan 09 2022 *)
%o (Haskell)
%o import Data.List (unfoldr)
%o a049084 n = a049084_list !! (fromInteger n - 1)
%o a049084_list = unfoldr x (1, 1, a000040_list) where
%o x (i, z, ps'@(p:ps)) | i == p = Just (z, (i + 1, z + 1, ps))
%o | i /= p = Just (0, (i + 1, z, ps'))
%o -- _Reinhard Zumkeller_, Apr 17 2012, Mar 31 2012, Sep 15 2011
%o (PARI) a(n)=if(isprime(n),primepi(n),0) \\ _Charles R Greathouse IV_, Jan 08 2013
%Y a(n) = A091227(A091202(n)).
%Y Cf. A143541.
%K nonn,easy
%O 1,3
%A _N. J. A. Sloane_
%E Name clarified by _Alonso del Arte_, Feb 07 2020 at the suggestion of _David A. Corneth_