### Communities

tag:snake search within a tag
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
created:<1w created < 1 week ago
post_type:xxxx type of post
Challenges

# Give the fool's fibonacci sequence

+2
−1

Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2:

2,8,34,144,610,2584,10946,46368,196418,832040


However, I made a mistake in deriving my formula, and my code output a different sequence which is accurate for the first couple terms and then begins to diverge:

2,8,34,140,578,2384,9834,40564,167322,690184


My sequence is defined by:

\begin{array}{rcl} f(0) &=& 0 \\ f(1) &=& 2 \\ f(n) &=&\displaystyle 2 + 3f(n-1) + 4f(n-2) + 2\sum_{0}^{n-3}f\\ \end{array}

or in terms of my original Haskell code:

z=zipWith(+)
g=z((*2)<$>0:0:g)$z(0:g)$(*2)<$>scanl(+)1g


Your task is to implement a sequence of integers, which has my incorrect sequence as every third value. The other values can be whatever you want them to be, it simply must have the above sequence as every third value. The sequence can begin at the 0th, 1st, or 2nd index, whichever you please.

This is code-golf so the goal is to minimize the size of your program as measured in bytes.

Why does this post require moderator attention?