|
|
A010052
|
|
Characteristic function of squares: a(n) = 1 if n is a square, otherwise 0.
|
|
372
|
|
|
1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,1
|
|
COMMENTS
|
Also, the decimal expansion of Sum_{n >= 0} 1/(10^n)^n. - Eric Desbiaux, Mar 15 2009, rephrased and simplified by M. F. Hasler, Jan 26 2013
|
|
REFERENCES
|
Jean-Paul Allouche and Jeffrey Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, pp. 3-4, also p. 166, Ex. 5.5.1.
Tom M. Apostol, Introduction to Analytic Number Theory, Springer-Verlag, 1976, page 48, Problem 20.
Michael D. Hirschhorn, The Power of q, Springer, 2017. See phi(q) page 8.
Michel Rigo, Formal Languages, Automata and Numeration Systems, 2 vols., Wiley, 2014. Mentions this sequence - see "List of Sequences" in Vol. 2.
Stephen Wolfram, A New Kind of Science, Wolfram Media, 2002, p. 55.
|
|
LINKS
|
|
|
FORMULA
|
a(n) = floor(sqrt(n)) - floor(sqrt(n-1)), for n > 0.
a(n) = A000005(n) mod 2, n > 0. - Ahmed Fares (ahmedfares(AT)my-deja.com), Apr 19 2001
G.f. A(x) satisfies: 0 = f(A(x), A(x^2), A(x^4)) where f(u, v, w) = (u-w)^2 - (v-w)*(v+w-1) - Michael Somos, Jul 19 2004
a(n) = f(n,0) with f(x,y) = f(x-2*y-1,y+1) if x > 0, otherwise 0^(-x). - Reinhard Zumkeller, Sep 26 2008
a(n) = Sum_{d|n} (-1)^bigomega(d), for n >= 1. - Benoit Cloitre, Oct 25 2009
a(n*m) = a(n/gcd(n,m))*a(m/gcd(n,m)) for all n and m > 0 (conjectured). - Velin Yanev, Feb 13 2019 [Proof from Michael B. Porter, Feb 16 2019: If nm is a square, nm = product_i (p_i^2), where p_i are prime, not necessarily distinct. Each p_i either appears twice in n, twice in m, or one time in each and therefore in the gcd. So n/gcd(n,m) and m/gcd(n,m) are both squares. If nm is not a square, there is a q_j that appears in one of n or m but not in the gcd. So either n/gcd(n,m) or m/gcd(n,m) is not a square.]
G.f.: A(q) = Sum_{n >= 0} q^(2*n)*Product_{k >= 2*n+1} 1 - (-q)^k. - Peter Bala, Feb 22 2021
Multiplicative with a(p^e) = 1 if e is even, and 0 otherwise. - Amiram Eldar, Dec 29 2022
a(n) = Sum_{d|n} mobius(core(n)), where core(n) = A007913(n). - Peter Bala, Jan 24 2024
|
|
EXAMPLE
|
G.f. = 1 + x + x^4 + x^9 + x^16 + x^25 + x^36 + x^49 + x^64 + x^81 + ...
|
|
MAPLE
|
readlib(issqr): f := i->if issqr(i) then 1 else 0; fi; [ seq(f(i), i=0..100) ];
|
|
MATHEMATICA
|
lst = {}; Do[AppendTo[lst, 2*Sum[Floor[n/k] - Floor[(n - 1)/k], {k, Floor[Sqrt[n]]}] - DivisorSigma[0, n]], {n, 93}]; Prepend[lst, 1] (* Eric Desbiaux, Jan 29 2012 *)
Table[If[IntegerQ[Sqrt[n]], 1, 0], {n, 0, 100}] (* Harvey P. Dale, Jul 19 2014 *)
a[n_] := SeriesCoefficient[1/(1 - q)* QHypergeometricPFQ[{-q, -q}, {-(q^2)}, -q, -q], {q, 0, Abs@n}] (* Mats Granvik, Jan 01 2016 *)
Range[0, 120] /. {n_ /; IntegerQ@ Sqrt@ n -> 1, n_ /; n != 1 -> 0} (* Michael De Vlieger, Jan 02 2016 *)
a[n_] := Sum[If[Mod[n, k] == 0, Re[Sqrt[LiouvilleLambda[k]]*Sqrt[LiouvilleLambda[n/k]]], 0], {k, 1, n}] (* Mats Granvik, Aug 10 2018 *)
|
|
PROG
|
(PARI) {a(n) = issquare(n)};
(PARI) a(n)=if(n<1, 1, sumdiv(n, d, (-1)^bigomega(d))) \\ Benoit Cloitre, Oct 25 2009
(PARI) a(n) = if (n<1, 1, direuler( p=2, n, 1/ (1 - X^2 ))[n]); \\ Michel Marcus, Mar 08 2015
(Haskell)
a010052 n = fromEnum $ a000196 n ^ 2 == n
a010052_list = concat (iterate (\xs -> xs ++ [0, 0]) [1])
(Python)
def A010052(n): return int(math.isqrt(n)**2==n) ## appears to be faster than sympy.ntheory.primetest.is_square, up to 10^8 at least.
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,nice,easy,mult
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|