login
Primes together with primes multiplied by 2.
20

%I #40 Oct 17 2024 12:52:16

%S 2,3,4,5,6,7,10,11,13,14,17,19,22,23,26,29,31,34,37,38,41,43,46,47,53,

%T 58,59,61,62,67,71,73,74,79,82,83,86,89,94,97,101,103,106,107,109,113,

%U 118,122,127,131,134,137,139,142,146,149,151,157,158,163,166

%N Primes together with primes multiplied by 2.

%C For n > 1, a(n) is position of primes in A026741.

%C For n > 1, a(n) is the position of the ones in A046079. - _Ant King_, Jan 29 2011

%C A251561(a(n)) != a(n). - _Reinhard Zumkeller_, Dec 27 2014

%C Number of terms <= n is pi(n) + pi(n/2). - _Robert G. Wilson v_, Aug 04 2017

%C Number of terms <=10^k: 7, 40, 263, 1898, 14725, 120036, 1013092, 8762589, 77203401, 690006734, 6237709391, 56916048160, 523357198488, 4843865515369, ..., . - _Robert G. Wilson v_, Aug 04 2017

%C Complement of A264828. - _Chai Wah Wu_, Oct 17 2024

%H T. D. Noe, <a href="/A001751/b001751.txt">Table of n, a(n) for n = 1..10000</a>

%t Select[Range[163], Or[PrimeQ[#], PrimeQ[1/2 #]] &] (* _Ant King_, Jan 29 2011 *)

%t upto=200;With[{pr=Prime[Range[PrimePi[upto]]]},Select[Sort[Join[pr,2pr]],# <= upto&]] (* _Harvey P. Dale_, Sep 23 2014 *)

%o (Haskell)

%o a001751 n = a001751_list !! (n-1)

%o a001751_list = 2 : filter (\n -> (a010051 $ div n $ gcd 2 n) == 1) [1..]

%o -- _Reinhard Zumkeller_, Jun 20 2011 (corrected, improved), Dec 17 2010

%o (PARI) isA001751(n)=isprime(n/gcd(n,2)) || n==2

%o (PARI) list(lim)=vecsort(concat(primes(primepi(lim)), 2* primes(primepi(lim\2)))) \\ _Charles R Greathouse IV_, Oct 31 2012

%o (Python)

%o from sympy import primepi

%o def A001751(n):

%o def bisection(f,kmin=0,kmax=1):

%o while f(kmax) > kmax: kmax <<= 1

%o while kmax-kmin > 1:

%o kmid = kmax+kmin>>1

%o if f(kmid) <= kmid:

%o kmax = kmid

%o else:

%o kmin = kmid

%o return kmax

%o def f(x): return int(n+x-primepi(x)-primepi(x>>1))

%o return bisection(f,n,n) # _Chai Wah Wu_, Oct 17 2024

%Y Union of A001747 and A000040.

%Y Subsequence of A039698 and of A033948.

%Y Cf. A026741, A046079, A178156, A251561, A264828.

%K nonn,easy

%O 1,1

%A _N. J. A. Sloane_