A042965 Nonnegative integers not congruent to 2 mod 4.
0, 1, 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 32, 33, 35, 36, 37, 39, 40, 41, 43, 44, 45, 47, 48, 49, 51, 52, 53, 55, 56, 57, 59, 60, 61, 63, 64, 65, 67, 68, 69, 71, 72, 73, 75, 76, 77, 79, 80, 81, 83, 84, 85, 87, 88, 89, 91, 92
Offset: 1
Examples
G.f. = x^2 + 3*x^3 + 4*x^4 + 5*x^5 + 7*x^6 + 8*x^7 + 9*x^8 + 11*x^9 + 12*x^10 + ...
References
- R. K. Guy, Unsolved Problems in Number Theory, Springer, 1st edition, 1981. See section D9.
- J. V. Uspensky and M. A. Heaslet, Elementary Number Theory, McGraw-Hill, NY, 1939, p. 83.
Links
- Ray Chandler, Table of n, a(n) for n = 1..10000 (first 1000 terms from T. D. Noe)
- Pentti Haukkanen and László Tóth, An analogue of Ramanujan's sum with respect to regular integers (mod r), Ramanujan J., Vol. 27, No. 1 (2012), pp. 71-88.
- Ron Knott, Pythagorean Triples and Online Calculators.
- N. J. A. Sloane et al., Binary Quadratic Forms and OEIS (Index to related sequences, programs, references).
- Index entries for linear recurrences with constant coefficients, signature (1,0,1,-1).
Crossrefs
Programs
-
Haskell
a042965 = (`div` 3) . (subtract 3) . (* 4) a042965_list = 0 : 1 : 3 : map (+ 4) a042965_list -- Reinhard Zumkeller, Nov 09 2012
-
Magma
[n: n in [0..100] | not n mod 4 in [2]]; // Vincenzo Librandi, Sep 03 2015
-
Maple
a_list := proc(len) local rec; rec := proc(n) option remember; ifelse(n <= 4, [0, 1, 3, 4][n], rec(n-1) + rec(n-3) - rec(n-4)) end: seq(rec(n), n=1..len) end: a_list(76); # Peter Luschny, Aug 06 2022
-
Mathematica
nn=100; Complement[Range[0,nn], Range[2,nn,4]] (* Harvey P. Dale, May 21 2011 *) f[n_]:=Floor[(4*n-3)/3]; Array[f,70] (* Robert G. Wilson v, Jun 26 2012 *) LinearRecurrence[{1, 0, 1, -1}, {0, 1, 3, 4}, 70] (* L. Edson Jeffery, Jan 21 2015 *) Select[Range[0, 100], ! MemberQ[{2}, Mod[#, 4]] &] (* Vincenzo Librandi, Sep 03 2015 *)
-
PARI
a(n)=(4*n-3)\3 \\ Charles R Greathouse IV, Jul 25 2011
-
Python
def A042965(n): return (n<<2)//3-1 # Chai Wah Wu, Feb 10 2025
Formula
Recurrence: a(n) = a(n-1) + a(n-3) - a(n-4) for n>4.
a(n) = n - 1 + (3n-3-sqrt(3)*(1-2*cos(2*Pi*(n-1)/3))*sin(2*Pi*(n-1)/3))/9. Partial sums of the period-3 sequence 0, 1, 1, 2, 1, 1, 2, 1, 1, 2, ... (A101825). - Ralf Stephan, May 19 2013
G.f.: A(x) = x^2*(1+x)^2/((1-x)^2*(1+x+x^2)); a(n)=Sum{k=0..floor(n/2)}, binomial(n-k-1, k)*A001045(n-2*k), n>0. - Paul Barry, Jan 16 2005, R. J. Mathar, Dec 09 2009
a(n) = floor((4*n-3)/3). - Gary Detlefs, May 14 2011
A214546(a(n)) != 0. - Reinhard Zumkeller, Jul 20 2012
From Michael Somos, May 18 2013: (Start)
Euler transform of length 3 sequence [3, -2, 1].
a(2-n) = -a(n). (End)
From Wesley Ivan Hurt, Jun 10 2016: (Start)
a(n) = (12*n-12+3*cos(2*n*Pi/3)+sqrt(3)*sin(2*n*Pi/3))/9.
a(3k) = 4k-1, a(3k-1) = 4k-3, a(3k-2) = 4k-4. (End)
a(n) = round((4*n-4)/3). - Mats Granvik, Sep 24 2016
The g.f. A(x) satisfies (A(x)/x)^2 + A(x)/x = x*B(x)^2, where B(x) is the o.g.f. of A042968. - Peter Bala, Apr 12 2017
Sum_{n>=2} (-1)^n/a(n) = log(sqrt(2)+2)/sqrt(2) - (sqrt(2)-1)*log(2)/4. - Amiram Eldar, Dec 05 2021
From Peter Bala, Aug 03 2022: (Start)
a(n) = a(floor(n/2)) + a(1 + ceiling(n/2)) for n >= 2, with a(2) = 1 and a(3) = 3.
E.g.f.: (9 + 12*exp(x)*(x - 1) + exp(-x/2)*(3*cos(sqrt(3)*x/2) + sqrt(3)*sin(sqrt(3)*x/2)))/9. - Stefano Spezia, Apr 05 2023
Extensions
Edited by N. J. A. Sloane at the suggestion of Andrew S. Plewe, Peter Pein and Ralf Stephan, Jun 17 2007
Typos fixed in Gary Detlefs's formula and in PARI program by Reinhard Zumkeller, Nov 09 2012
Comments