%I #44 Sep 08 2022 08:45:19
%S 3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,
%T 1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,
%U 1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1,1,3,1
%N a(n) = gcd(n,3).
%C For n>1: a(n) = GCD of the n-th and (n+2)-th triangular numbers = A050873(A000217(n+2), A000217(n)). - _Reinhard Zumkeller_, May 28 2007
%C From _Klaus Brockhaus_, May 24 2010: (Start)
%C Continued fraction expansion of (3+sqrt(17))/2.
%C Decimal expansion of 311/999. (End)
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,1).
%F a(n) = 1 + 2*[3|n] = 1 + 2(1 + 2*cos(2*n*Pi/3))/3, where [x|y] = 1 when x divides y, 0 otherwise.
%F a(n) = a(n-3) for n>2.
%F Multiplicative with a(p^e, 3) = gcd(p^e, 3). - _David W. Wilson_, Jun 12 2005
%F O.g.f.: -(3+x+x^2)/((x-1)*(x^2+x+1)). - _R. J. Mathar_, Nov 24 2007
%F Dirichlet g.f. zeta(s)*(1+2/3^s). - _R. J. Mathar_, Apr 08 2011
%F a(n) = 2*floor(((n-1) mod 3)/2) + 1. - _Gary Detlefs_, Dec 28 2011
%F a(n) = 3^(1 - sgn(n mod 3)). - _Wesley Ivan Hurt_, Jul 24 2016
%F a(n) = 3/(1 + 2*((n^2) mod 3)). - _Timothy Hopper_, Feb 25 2017
%F a(n) = (5 + 4*cos(2*n*Pi/3))/3. - _Wesley Ivan Hurt_, Oct 04 2018
%p A109007:=n->gcd(n,3): seq(A109007(n), n=0..100); # _Wesley Ivan Hurt_, Jul 24 2016
%t GCD[Range[0,100],3] (* or *) PadRight[{},110,{3,1,1}] (* _Harvey P. Dale_, Jun 28 2015 *)
%o (PARI) a(n)=gcd(n,3) \\ _Charles R Greathouse IV_, Sep 24 2015
%o (Magma) [Gcd(n,3) : n in [0..100]]; // _Wesley Ivan Hurt_, Jul 24 2016
%Y Cf. A000217, A026741, A050873, A109004, A130334.
%Y Cf. A178255 (decimal expansion of (3+sqrt(17))/2). - _Klaus Brockhaus_, May 24 2010
%K nonn,easy,mult
%O 0,1
%A _Mitch Harris_