%I #97 Aug 22 2023 11:58:19
%S 1,2,2,3,4,7,12,23,44,87,172,343,684,1367,2732,5463,10924,21847,43692,
%T 87383,174764,349527,699052,1398103,2796204,5592407,11184812,22369623,
%U 44739244,89478487,178956972,357913943,715827884,1431655767,2863311532
%N Number of distinct quadratic residues mod 2^n.
%C Number of distinct n-digit suffixes of base 2 squares.
%C a(n) counts the elements of A234000 smaller than 2^n plus the zero: a(7)=23 counts the elements of {0, 1, 4, 9, ..., 113, 121}, for example. - _R. J. Mathar_, Oct 11 2014
%C Conjecture: a(n) = 2 + (the number of A004215 entries < 2^n), for n>0. - _Tilman Neumann_, Sep 20 2020
%H Vincenzo Librandi, <a href="/A023105/b023105.txt">Table of n, a(n) for n = 0..1000</a>
%H Lee Hae-hwang, <a href="/A023105/a023105.pdf">Sequences of Growing Networks</a>
%H W. D. Stangl, <a href="http://www.maa.org/programs/faculty-and-departments/classroom-capsules-and-notes/counting-squares-in-zn">Counting Squares in Z_n</a>, Mathematics Magazine, pp. 285-289, Vol. 69 No. 4 (October 1996).
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (2,1,-2).
%F a(n) = floor( (2^n+10)/6 ).
%F a(n) = (2^n + 9 - (-1)^n)/6 for n > 0. - _David S. Dodson_, Jan 06 2013
%F G.f.: (1-3*x^2-x^3)/((1-x)*(1+x)*(1-2*x)). - _Colin Barker_, Mar 08 2012
%F a(0)=1, a(1)=2. a(n) = 2*a(n-1)-2 if n is even, a(n) = 2*a(n-1)-1 if n is odd. - _Vincenzo Librandi_, Apr 21 2012
%F a(n) = 2*a(n-1) + a(n-2) - 2*a(n-3) for n > 0. - _Joerg Arndt_, Apr 21 2012
%F a(0)=1, a(1)=2, a(n+2) = a(n+1) + A001045(n) for n >= 1. - _Lee Hae-hwang_, Jun 16 2014
%F a(n) = A000224(2^n). - _R. J. Mathar_, Oct 10 2014
%F a(n) = A005578(n-1) + 1, n > 0. - _Carl Joshua Quines_, Jul 17 2019
%F E.g.f.: (exp(2*x) + 9*exp(x) - 3 - exp(-x))/6. - _G. C. Greubel_, Aug 10 2022
%t CoefficientList[Series[(1-3*x^2-x^3)/((1-x)*(1+x)*(1-2*x)),{x,0,35}],x] (* _Vincenzo Librandi_, Apr 21 2012 *)
%t LinearRecurrence[{2,1,-2},{1,2,2,3},40] (* _Harvey P. Dale_, Mar 05 2016 *)
%o (Magma) [Floor((2^n+10)/6): n in [0..30]]; // _Vincenzo Librandi_, Apr 21 2012
%o (PARI) a(n)=(2^n+10)\6 \\ _Charles R Greathouse IV_, Apr 21 2012
%o (Haskell)
%o a 0 = 1
%o a 1 = 2
%o a n | even n = 2*a(n-1)-2
%o a n | odd n = 2*a(n-1)-1
%o -- _James Spahlinger_, Oct 07 2012
%o (SageMath) [(2^n +9 -(-1)^n -3*bool(n==0))/6 for n in (0..30)] # _G. C. Greubel_, Aug 10 2022
%o (Python)
%o def A023105(n): return ((1<<n-1)+5)//3 if n else 1 # _Chai Wah Wu_, Aug 22 2023
%Y Cf. A000224, A001045, A004315, A005578, A234000.
%K nonn,easy
%O 0,2
%A _David W. Wilson_