login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A039300 Number of distinct quadratic residues mod 3^n. 6
1, 2, 4, 11, 31, 92, 274, 821, 2461, 7382, 22144, 66431, 199291, 597872, 1793614, 5380841, 16142521, 48427562, 145282684, 435848051, 1307544151, 3922632452, 11767897354, 35303692061, 105911076181, 317733228542, 953199685624 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,2

COMMENTS

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

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

REFERENCES

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

LINKS

Vincenzo Librandi, Table of n, a(n) for n = 0..1000

W. D. Stangl, Counting Squares in Z_n, Mathematics Magazine, pp. 285-289, Vol. 69 No. 4 (October 1996).

Index entries for linear recurrences with constant coefficients, signature (3,1,-3).

FORMULA

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

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

a(n) = (3^(n+1) + 6 + (-1)^(n+1))/8. - Lekraj Beedassy, Jan 07 2005

G.f.: (1 - x - 3*x^2)/((1 - x)*(1 + x)*(1 - 3*x)). - Michael Somos, Mar 27 2005

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

a(n) = 3*a(n-1) + a(n-2) - 3*a(n-3). Vincenzo Librandi, Apr 21 2012

a(n) = A000224(3^n). - R. J. Mathar, Sep 28 2017

E.g.f.: (1/8)*exp(-x)*(-1+6*exp(2*x)+3*exp(4*x)). - Stefano Spezia, Sep 04 2018

MAPLE

A039300 := proc(n)

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

end proc:

seq(A039300(n), n=0..30) ; # R. J. Mathar, Sep 28 2017

MATHEMATICA

CoefficientList[Series[(1-x-3x^2)/((1-x)(1+x)(1-3x)), {x, 0, 30}], x] (* Vincenzo Librandi, Apr 21 2012 *)

Table[Floor((3^n+3)*3/8), {n, 0, 30}] (* Bruno Berselli, Apr 21 2012 *)

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

PROG

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

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

(MAGMA) [(3^(n+1) + 6 + (-1)^(n+1))/8: n in [0..30]]; // Vincenzo Librandi, Apr 21 2012

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

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

CROSSREFS

Cf. A033113, A000224, A015518, A023105.

Sequence in context: A148162 A148163 A274775 * A247333 A118974 A119020

Adjacent sequences:  A039297 A039298 A039299 * A039301 A039302 A039303

KEYWORD

nonn,easy

AUTHOR

David W. Wilson

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
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 23 01:30 EDT 2021. Contains 347609 sequences. (Running on oeis4.)