login
Characteristic function of {1} union {primes}: 1 if n is 1 or a prime, else 0.
27

%I #61 Feb 23 2024 07:26:04

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

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

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

%N Characteristic function of {1} union {primes}: 1 if n is 1 or a prime, else 0.

%C Characteristic function of noncomposite numbers (see A008578). - _Omar E. Pol_, Oct 07 2013

%H Robert Israel, <a href="/A080339/b080339.txt">Table of n, a(n) for n = 1..10000</a>

%H Aminu Alhaji Ibrahim, Sa’idu Isah Abubaka, <a href="http://dx.doi.org/10.4236/apm.2016.66028">Aunu Integer Sequence as Non-Associative Structure and Their Graph Theoretic Properties</a>, Advances in Pure Mathematics, 2016, 6, 409-419.

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

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

%F a(1)=1, and a(n) = Prod_{k=1...n-1}(k/n)^2 where (a/b) is the Jacobi symbol and n>1. - _Dimitri Papadopoulos_, Jan 13 2016

%p 1,seq(`if`(isprime(i),1,0),i=2..100); # _Robert Israel_, Jan 11 2016

%t Table[Which[n == 1, 1, PrimeQ[n], 1, True, 0], {n, 110}] (* _Harvey P. Dale_, Oct 03 2011 *)

%t Table[Boole[PrimeOmega[n] < 2], {n, 100}] (* _Alonso del Arte_, Nov 19 2013 *)

%o (PARI) a(n) = (n==1) + isprime(n); \\ _Michel Marcus_, Jan 13 2016

%Y Cf. A010051, A080355.

%Y Cf. A036234 (partial sums).

%K nonn,easy

%O 1,1

%A _N. J. A. Sloane_, Mar 21 2003