Post History
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,...
#3: Post edited
- Recently [I asked](https://codegolf.stackexchange.com/q/264316/56656) 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:
- ```haskell
- z=zipWith(+)
- g=z((*2)<$>0:0:g)$z(0:g)$(*2)<$>scanl(+)1g
- ```
Your task is to implement a sequence, 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.
- Recently [I asked](https://codegolf.stackexchange.com/q/264316/56656) 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:
- ```haskell
- 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.
#1: Initial revision
Give the fools fibonacci sequence
Recently [I asked](https://codegolf.stackexchange.com/q/264316/56656) 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: ```haskell z=zipWith(+) g=z((*2)<$>0:0:g)$z(0:g)$(*2)<$>scanl(+)1g ``` Your task is to implement a sequence, 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.