login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A158387 a(n) = -1 if n is a square, 1 if n is not a square. 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, -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

Antti Karttunen, Table of n, a(n) for n = 1..65537

Index to divisibility sequences

Index entries for sequences computed from exponents in factorization of n

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.

EXAMPLE

a(12) = (-1)^6 = 1.

MATHEMATICA

Array[1 - 2 Boole[OddQ@ DivisorSigma[0, #]] &, 100] (* Michael De Vlieger, Nov 03 2017 *)

PROG

(PARI) a(n) = (-1)^numdiv(n) \\ Michel Marcus, Jun 13 2013

(PARI) a(n)=(-1)^issquare(n) \\ Charles R Greathouse IV, Jun 13 2013

(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. A000005, A010052.

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).

Sequence in context: A063747 A077008 * A265643 A008836 A087960 A164660

Adjacent sequences:  A158384 A158385 A158386 * A158388 A158389 A158390

KEYWORD

sign,easy

AUTHOR

Jaroslav Krizek, Mar 17 2009

EXTENSIONS

Description corrected by David A. Corneth, Nov 03 2017

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified November 17 10:07 EST 2018. Contains 317275 sequences. (Running on oeis4.)