login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A350129
a(0) = 0; thereafter a(n) = a(n-1)/2 + n if a(n-1) is even, otherwise a(n) = a(n-1) + a(n-2).
2
0, 1, 1, 2, 5, 7, 12, 13, 25, 38, 29, 67, 96, 61, 157, 218, 125, 343, 468, 253, 721, 974, 509, 1483, 1992, 1021, 3013, 4034, 2045, 6079, 8124, 4093, 12217, 16310, 8189, 24499, 32688, 16381, 49069, 65450, 32765, 98215, 130980, 65533, 196513, 262046, 131069, 393115, 524184
OFFSET
0,4
COMMENTS
Terms are even if and only if n is a multiple of 3. This can be shown by induction. The predictable pattern means the sequence is given by a linear recurrence with constant coefficients. - Andrew Howroyd, Dec 15 2021
FORMULA
G.f.: x*(1 + 2*x^3)*(1 + x + 2*x^2 - x^3 + x^4)/((1 - x)^2*(1 + x + x^2)^2*(1 - 2*x^3)). - Andrew Howroyd, Dec 15 2021
From Ben Whitmore, Dec 17 2021: (Start)
a(n) = 2^(n/3+3)-2n-8 if n == 0 (mod 3);
a(n) = 2^((n+5)/3)-3 if n == 1 (mod 3);
a(n) = 3*2^((n+4)/3)-2n-7 if n == 2 (mod 3).
(End)
EXAMPLE
Start at a(0)=0.
0 is even, so to get a(1), divide by 2 and add n: a(1) = 0/2 + 1 = 1.
1 is odd, so to get a(2), add the previous term: a(2) = a(1) + a(0) = 1 + 1 = 1.
Continuing, we get
n a(n)
- ----
0 0
1 0/2 = 0 + 1 = 1
2 1 + 0 = 1
3 1 + 1 = 2
4 2/2 = 1 + 4 = 5
5 5 + 2 = 7
6 7 + 5 = 12
7 12/2 = 6 + 7 = 13
MATHEMATICA
a[0] = 0; a[n_] := a[n] = If[EvenQ[a[n - 1]], a[n - 1]/2 + n, a[n - 1] + a[n - 2]]; Array[a, 50, 0] (* Amiram Eldar, Dec 15 2021 *)
PROG
(Python)
a = [0]
[a.append(a[-1] + a[-2] if a[-1]%2 else a[-1]//2 + n) for n in range(1, 49)]
print(a) # Michael S. Branicky, Dec 15 2021
(PARI) seq(n)={my(a=vector(n)); a[1]=0; for(n=2, #a, a[n] = if(a[n-1]%2==0, a[n-1]/2+(n-1), a[n-1]+a[n-2])); a} \\ Andrew Howroyd, Dec 15 2021
(PARI) concat([0], Vec((1 + 2*x^3)*(1 + x + 2*x^2 - x^3 + x^4)/((1 - x)^2*(1 + x + x^2)^2*(1 - 2*x^3)) + O(x^30))) \\ Andrew Howroyd, Dec 15 2021
CROSSREFS
Sequence in context: A088823 A302294 A007445 * A159699 A063217 A088821
KEYWORD
nonn,easy
AUTHOR
Gavin Lupo, Dec 15 2021
STATUS
approved