A047229 Numbers that are congruent to {0, 2, 3, 4} mod 6.
0, 2, 3, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 26, 27, 28, 30, 32, 33, 34, 36, 38, 39, 40, 42, 44, 45, 46, 48, 50, 51, 52, 54, 56, 57, 58, 60, 62, 63, 64, 66, 68, 69, 70, 72, 74, 75, 76, 78, 80, 81, 82, 84
Offset: 1
Links
- Vincenzo Librandi, Table of n, a(n) for n = 1..10000
- A. S. Besicovitch, On the density of certain sequences of integers, Mathematische Annalen, Vol. 110, No. 1 (1935), pp. 336-341; alternative link.
- Hsien-Kuei Hwang, Svante Janson and Tsung-Hsi Tsai, Exact and Asymptotic Solutions of a Divide-and-Conquer Recurrence Dividing at Half: Theory and Applications, ACM Transactions on Algorithms, Vol. 13, No. 4 (2017), Article #47; ResearchGate link; preprint, 2016.
- Index entries for linear recurrences with constant coefficients, signature (2,-2,2,-1)
Programs
-
Haskell
a047229 n = a047229_list !! (n-1) a047229_list = filter ((`notElem` [1,5]) . (`mod` 6)) [0..] -- Reinhard Zumkeller, Jun 30 2012
-
Magma
[ n : n in [0..150] | n mod 6 in [0, 2, 3, 4]] ; // Vincenzo Librandi, Jun 01 2011
-
Mathematica
Select[Range[0,100],MemberQ[{0,2,3,4},Mod[#,6]]&] (* Harvey P. Dale, Aug 15 2011 *) a[ n_] := With[ {m = n - 1}, {2, 3, 4, 0}[[Mod[m, 4, 1]]] + Quotient[ m, 4] 6]; (* Michael Somos, Oct 05 2015 *)
-
PARI
a(n)=(n-1)\4*6+[4,0,2,3][n%4+1] \\ Charles R Greathouse IV, Oct 28 2011
-
Python
def A047229(n): return 3*(n-1>>1&-2)+(4,0,2,3)[n&3] # Chai Wah Wu, Nov 18 2024
Formula
a(n) = (6*(n-1) - (1+(-1)^n)*(-1)^(n*(1+(-1)^n)/4))/4; also a(n) = (6*(n-1) - (-i)^n - i^n)/4, where i is the imaginary unit. - Bruno Berselli, Nov 08 2010
G.f.: x^2*(2-x+2*x^2) / ( (x^2+1)*(x-1)^2 ). - R. J. Mathar, Oct 08 2011
a(n) = floor((6*n-5)/4) + floor((1/2)*cos((n+2)*Pi/2) + 1/2). - Gary Detlefs, Oct 28 2011 and corrected by Aleksey A. Solomein, Feb 08 2016
a(n) = a(n-1) + a(n-4) - a(n-5), n>4. - Gionata Neri, Apr 15 2015
a(n) = -a(2-n) for all n in Z. - Michael Somos, Oct 05 2015
a(n) = n + 2*floor((n-2)/4) + floor(f(n+2)/3), where f(n) = n mod 4. - Aleksey A. Solomein, Feb 08 2016
a(n) = (3*n - 3 - cos(n*Pi/2))/2. - Wesley Ivan Hurt, Oct 02 2017
Sum_{n>=2} (-1)^n/a(n) = log(3)/2 - log(2)/3. - Amiram Eldar, Dec 12 2021
Comments