|
|
A005171
|
|
Characteristic function of nonprimes: 0 if n is prime, else 1.
|
|
79
|
|
|
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, 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, 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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
|
|
REFERENCES
|
Douglas Hofstadter, Fluid Concepts and Creative Analogies: Computer Models of the Fundamental Mechanisms of Thought.
|
|
LINKS
|
|
|
FORMULA
|
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]
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
|
|
MAPLE
|
if isprime(n) then
0 ;
else
1 ;
end if;
|
|
MATHEMATICA
|
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 *)
|
|
PROG
|
(PARI) a(n)=if(n<1, 0, !isprime(n)) /* Michael Somos, Jun 08 2005 */
(Haskell)
(Python)
from sympy import isprime
def a(n): return int(not isprime(n))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|