OFFSET
0,10
COMMENTS
Apparently, |a(n)|^(1/n) < 1.100276355... = (A347177^2 + A347178^2)^(1/4). - Jon E. Schoenfield, Jun 22 2022
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
Index entries for linear recurrences with constant coefficients, signature (0,0,0,-1,0,-1).
FORMULA
a(n) = a(n-1) + (2*(n mod 2) - 1)*(a(n-3) + a(n-2) + a(n-1)), with a(0) = 1, a(1) = 0, and a(2) = 0.
G.f.: (1 + x^3 + x^4 + x^5)/(1 + x^4 + x^6). - Stefano Spezia, Jun 22 2022
EXAMPLE
For n = 12, a(12) = 1: The previous three terms are a(9) = -2, a(10) = 1, a(11) = 0, whose sum is -1. 12 is even, so we subtract that sum from the previous term, a(11) = 0, which gives a(12) = 0 - (-1) = 1.
MATHEMATICA
CoefficientList[Series[(1 + x^3 + x^4 + x^5)/(1 + x^4 + x^6), {x, 0, 65}], x] (* Michael De Vlieger, Jun 22 2022 *)
PROG
(Python)
def a(n):
if n in [0, 1, 2]:
return [1, 0, 0][n]
else:
previous_terms = [1, 0, 0]
for i in range(n - 2):
previous_three_terms = previous_terms[-3:]
previous_three_terms_sum = sum(previous_three_terms)
current_term = previous_terms[-1]
if i % 2 == 0:
previous_terms.append(current_term + previous_three_terms_sum)
else:
previous_terms.append(current_term - previous_three_terms_sum)
return previous_terms[-1]
print([a(n) for n in range(66)])
(Python)
a, terms = [1, 0, 0], 66
[a.append(a[-1]-(-1)**(n%2)*sum(a[-3:])) for n in range(3, terms)]
print(a) # Michael S. Branicky, Jun 22 2022
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Nate Shaw, Jun 20 2022
STATUS
approved