login
A271478
If n is even, a(n)=n/2, otherwise 2*n+2.
3
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,2
COMMENTS
Arises in studying A266569.
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
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
PROG
(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
CROSSREFS
Sequence in context: A134829 A245966 A130297 * A112032 A199049 A145917
KEYWORD
nonn,easy
AUTHOR
N. J. A. Sloane, Apr 10 2016
STATUS
approved