A271478 If n is even, a(n)=n/2, otherwise 2*n+2.
0, 4, 1, 8, 2, 12, 3, 16, 4, 20, 5, 24, 6, 28, 7, 32, 8, 36, 9, 40, 10, 44, 11, 48, 12, 52, 13, 56, 14, 60, 15, 64, 16, 68, 17, 72, 18, 76, 19, 80, 20, 84, 21, 88, 22, 92, 23, 96, 24, 100, 25, 104, 26, 108, 27, 112, 28, 116, 29, 120, 30, 124, 31, 128, 32, 132, 33, 136, 34, 140, 35
Offset: 0
Links
- Colin Barker, Table of n, a(n) for n = 0..1000
- Index entries for linear recurrences with constant coefficients, signature (0,2,0,-1).
Programs
-
Maple
f:=n->if n mod 2 = 0 then n/2 else 2*n+2; fi; [seq(f(n),n=0..100)];
-
Mathematica
Table[(5 n - (-1)^n (3 n + 4) + 4)/4, {n, 0, 70}] (* Ilya Gutkovskiy, Apr 11 2016 *)
-
PARI
concat(0, Vec(x*(4+x)/((1-x)^2*(1+x)^2) + O(x^50))) \\ Colin Barker, Apr 11 2016
-
PARI
a(n) = if (n % 2, 2*n+2, n/2); \\ Michel Marcus, Apr 11 2016
-
Python
for n in range(0,10**3): if(not n%2):print((int)(n/2)) else:print(2*n+2) # Soumil Mandal, Apr 11 2016
Formula
From Colin Barker, Apr 11 2016: (Start)
a(n) = 2*a(n-2)-a(n-4) for n>3.
G.f.: x*(4+x) / ((1-x)^2*(1+x)^2). (End)
a(n) = (5*n - (-1)^n*(3*n + 4) + 4)/4. - Ilya Gutkovskiy, Apr 11 2016
Comments