login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A039300 Number of distinct quadratic residues mod 3^n. 8

%I #49 Sep 08 2022 08:44:53

%S 1,2,4,11,31,92,274,821,2461,7382,22144,66431,199291,597872,1793614,

%T 5380841,16142521,48427562,145282684,435848051,1307544151,3922632452,

%U 11767897354,35303692061,105911076181,317733228542,953199685624

%N Number of distinct quadratic residues mod 3^n.

%C Number of distinct n-digit suffixes of base 3 squares.

%C In general, for any odd prime p, the number s of quadratic residues mod p^n is given by s = (p^(n+1) + p + 2)/(2p + 2) for even n and s = (p^(n+1) + 2*p + 1)/(2p + 2) for odd n, see A000224. - _Lekraj Beedassy_, Jan 07 2005

%D J. V. Uspensky and M. A. Heaslet, Elementary Number Theory, McGraw-Hill, NY, 1939, p. 324.

%H Vincenzo Librandi, <a href="/A039300/b039300.txt">Table of n, a(n) for n = 0..1000</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 (3,1,-3).

%F a(n) = floor(3*(3^n + 3)/8).

%F a(n) = A033113(n) + 1.

%F a(n) = (3^(n+1) + 6 + (-1)^(n+1))/8. - _Lekraj Beedassy_, Jan 07 2005

%F G.f.: (1 - x - 3*x^2)/((1 - x)*(1 + x)*(1 - 3*x)). - _Michael Somos_, Mar 27 2005

%F a(n) = 2*a(n-1) + 3*a(n-2) - 3 with n > 1, a(0) = 1, a(1) = 1. - _Zerinvary Lajos_, Dec 14 2008

%F a(n) = 3*a(n-1) + a(n-2) - 3*a(n-3). _Vincenzo Librandi_, Apr 21 2012

%F a(n) = A000224(3^n). - _R. J. Mathar_, Sep 28 2017

%F E.g.f.: (1/8)*exp(-x)*(-1+6*exp(2*x)+3*exp(4*x)). - _Stefano Spezia_, Sep 04 2018

%p A039300 := proc(n)

%p floor((3^n+3)*3/8) ;

%p end proc:

%p seq(A039300(n),n=0..30) ; # _R. J. Mathar_, Sep 28 2017

%t CoefficientList[Series[(1-x-3x^2)/((1-x)(1+x)(1-3x)),{x,0,30}],x] (* _Vincenzo Librandi_, Apr 21 2012 *)

%t Table[Floor((3^n+3)*3/8),{n,0,30}] (* _Bruno Berselli_, Apr 21 2012 *)

%t CoefficientList[Series[1/8 E^-x (-1 + 6 E^(2 x) + 3 E^(4 x)), {x, 0, 30}], x]*Table[k!, {k, 0, 30}] (* _Stefano Spezia_, Sep 04 2018 *)

%o (PARI) {a(n) = if(n<0, 0, 3^n*3\8 + 1)}; /* _Michael Somos_,Mar 27 2005 */

%o (PARI) {a(n) = if(n<1, n==0, 3*a(n-1) - 2 + n%2)}; /* _Michael Somos_, Mar 27 2005 */

%o (Magma) [(3^(n+1) + 6 + (-1)^(n+1))/8: n in [0..30]]; // _Vincenzo Librandi_, Apr 21 2012

%o (Sage) [(3^(n+1) +6 -(-1)^n)/8 for n in (0..30)] # _G. C. Greubel_, Jul 14 2019

%o (GAP) List([0..30], n-> (3^(n+1) +6 -(-1)^n)/8) # _G. C. Greubel_, Jul 14 2019

%Y Cf. A033113, A000224, A015518, A023105.

%K nonn,easy

%O 0,2

%A _David W. Wilson_

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 14:32 EDT 2024. Contains 371914 sequences. (Running on oeis4.)