The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A005171 Characteristic function of nonprimes: 0 if n is prime, else 1. 79

%I #86 Dec 14 2023 08:57:01

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

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

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

%N Characteristic function of nonprimes: 0 if n is prime, else 1.

%C Number of orbits of length n in map whose periodic points are A023890. - _Thomas Ward_

%C Characteristic function of nonprimes A018252. - _Jonathan Vos Post_, Dec 30 2007

%C Triangle A157423 = A005171 in every column. A052284 = INVERT transform of A005171, and the eigensequence of triangle A157423. - _Gary W. Adamson_, Feb 28 2009

%D Douglas Hofstadter, Fluid Concepts and Creative Analogies: Computer Models of the Fundamental Mechanisms of Thought.

%H Antti Karttunen, <a href="/A005171/b005171.txt">Table of n, a(n) for n = 1..65537</a>

%H R. K. Guy, <a href="/A005165/a005165.pdf">The strong law of small numbers</a>. Amer. Math. Monthly 95 (1988), no. 8, 697-712. [Annotated scanned copy]

%H Yash Puri and Thomas Ward, <a href="http://www.cs.uwaterloo.ca/journals/JIS/VOL4/WARD/short.html">Arithmetic and growth of periodic orbits</a>, J. Integer Seqs., Vol. 4 (2001), #01.2.1.

%H Yash Puri and Thomas Ward, <a href="http://www.fq.math.ca/Scanned/39-5/puri.pdf">A dynamical property unique to the Lucas sequence</a>, Fibonacci Quarterly, Volume 39, Number 5 (November 2001), pp. 398-402.

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

%F a(n) = (1/n)* Sum_{ d divides n } mu(d)*A023890(n/d). E.g., a(6) = 1 since the 6th term of A023890 is 7 and the first term is 1. [edited by _Michel Marcus_, Dec 14 2023]

%F a(n) = 1 - A010051(n). - _Jonathan Vos Post_, Dec 30 2007

%F a(n) equals the first column in a table T defined by the recurrence: If n = k then T(n,k) = 1 else if k = 1 then T(n,k) = 1 - Product_{k divides n} of T(n,k), else if k divides n then T(n,k) = T(n/k,1). This is true since T(n,k) = 0 when k divides n and n/k is prime which results in Product_{k divides n} = 0 for the composite numbers and where k ranges from 2 to n. Therefore there is a remaining 1 in the expression 1-Product_{k divides n}, in the first column. Provided below is a Mathematica program as an illustration. - _Mats Granvik_, Sep 21 2013

%F a(n) = A057427(A239968(n)). - _Reinhard Zumkeller_, Mar 30 2014

%p A005171 := proc(n)

%p if isprime(n) then

%p 0 ;

%p else

%p 1 ;

%p end if;

%p end proc: # _R. J. Mathar_, May 26 2017

%t a[n_] := If[PrimeQ@ n, 0, 1]; Array[a, 105] (* _Robert G. Wilson v_, Jun 20 2011 *)

%t nn = 105; t[n_, k_] := t[n, k] = If[n == k, 1, If[k == 1, 1 - Product[t[n, k + i], {i, 1, n - 1}], If[Mod[n, k] == 0, t[n/k, 1], 1], 1]]; Table[t[n, 1], {n, 1, nn}] (* _Mats Granvik_, Sep 21 2013 *)

%o (PARI) a(n)=if(n<1, 0, !isprime(n)) /* _Michael Somos_, Jun 08 2005 */

%o (Haskell)

%o a005171 = (1 -) . a010051 -- _Reinhard Zumkeller_, Mar 30 2014

%o (Python)

%o from sympy import isprime

%o def a(n): return int(not isprime(n))

%o print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Oct 28 2021

%Y Cf. A010051, A018252, A023890.

%Y Cf. A157423, A157424, A052284, A050374.

%K nonn,easy

%O 1,1

%A _Russ Cox_

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 12 17:44 EDT 2024. Contains 372492 sequences. (Running on oeis4.)