login
Characteristic function of Sophie Germain primes.
21

%I #36 Nov 06 2022 07:47:59

%S 0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,

%T 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

%U 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

%N Characteristic function of Sophie Germain primes.

%H Reinhard Zumkeller, <a href="/A156660/b156660.txt">Table of n, a(n) for n = 0..10000</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Sophie_Germain_prime">Sophie Germain prime</a>

%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>

%F a(n) = if n and also 2*n+1 is prime then 1 else 0.

%F a(A005384(n)) = 1; a(A138887(n)) = 0; a(A053176(n)) = 0.

%F A156874(n) = Sum_{k=1..n} a(k). - _Reinhard Zumkeller_, Feb 18 2009

%F a(n) = A010051(n)*A010051(2*n+1).

%F For n>1 a(n) = floor((floor(phi(n)/(n-1)) + floor(phi(2*n+1)/(2*n)))/2). - _Enrique Pérez Herrero_, Apr 28 2012

%F For n>1 a(n) = floor(phi(2*n^2+n)/(2*n^2-2*n)). - _Enrique Pérez Herrero_, May 02 2012

%o (Haskell)

%o a156660 n = fromEnum $ a010051 n == 1 && a010051 (2 * n + 1) == 1

%o -- _Reinhard Zumkeller_, May 01 2012

%o (PARI) a(n)=isprime(n)&&isprime(2*n+1) \\ _Felix Fröhlich_, Aug 11 2014

%Y Cf. A156659.

%Y Cf. A005384, A156874, A092816.

%K nonn

%O 0,1

%A _Reinhard Zumkeller_, Feb 13 2009

%E Definition corrected by _Daniel Forgues_, Aug 04 2009