OFFSET
0,3
MAPLE
BinaryRecurrenceSequence := proc(b, c, u0:=0, u1:=1) local u;
u := proc(n) option remember; if n < 2 then return [u0, u1][n + 1] fi;
b*u(n - 1) + c*u(n - 2) end; u end:
EulerTransform := proc(a) local b;
b := proc(n) option remember; if n = 0 then return 1 fi; add(add(d * a(d),
d = NumberTheory:-Divisors(j)) * b(n-j), j = 1..n) / n end; b end:
a := EulerTransform(BinaryRecurrenceSequence(0, 2, 1)): seq(a(n), n=0..36);
PROG
(Sage) # uses[EulerTransform from A166861]
b = BinaryRecurrenceSequence(0, 2, 1)
a = EulerTransform(b)
print([a(n) for n in range(37)])
(Python)
from typing import Callable
from functools import cache
from sympy import divisors
def BinaryRecurrenceSequence(b:int, c:int, u0:int=0, u1:int=1) -> Callable:
@cache
def u(n: int) -> int:
if n < 2:
return [u0, u1][n]
return b * u(n - 1) + c * u(n - 2)
return u
def EulerTransform(a: Callable) -> Callable:
@cache
def b(n: int) -> int:
if n == 0:
return 1
s = sum(sum(d * a(d) for d in divisors(j)) * b(n - j)
for j in range(1, n + 1))
return s // n
return b
b = BinaryRecurrenceSequence(0, 2, 1)
a = EulerTransform(b)
print([a(n) for n in range(37)])
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Luschny, Nov 17 2022
STATUS
approved