|
|
A158387
|
|
a(n) = -1 if n is a square, 1 if n is not a square.
|
|
2
|
|
|
-1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
Equivalently, a(n) is the sign of (-1)^[parity of number of divisors of n].
|
|
LINKS
|
|
|
FORMULA
|
a(n) = (-1)^tau(n) = (-1)^A000005(n).
a(1) = -1, a(p) = 1, a(pq) = 1, a(pq...z) = 1, a(p^k) = (-1)^(k+1), for p, q, ..., z primes.
Sum_{k=1..n} a(k) ~ n - 2*sqrt(n). - Amiram Eldar, Jan 13 2024
|
|
EXAMPLE
|
a(12) = (-1)^6 = 1.
|
|
MATHEMATICA
|
Table[If[IntegerQ[Sqrt[n]], -1, 1], {n, 120}] (* Harvey P. Dale, Feb 17 2020 *)
|
|
PROG
|
(PARI) first(n) = my(res = vector(n, i, -1)); for(i = 1, sqrtint(n), res[i^2] = 1); res \\ David A. Corneth, Nov 03 2017
|
|
CROSSREFS
|
Cf. primes (A000040), pq = product of two distinct primes (A006881), pq...z = product of k (k > 2) distinct primes p, q, ..., z (A120944), p^k = prime powers (A000961(n) for n > 1), k = natural numbers (A000027).
|
|
KEYWORD
|
sign,easy
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|