Skip to main content
4 of 7
added 62 characters in body
zeppelin
  • 8.5k
  • 3
  • 21
  • 42

#ES6 (Javascript), 79, 67 bytes#

UPDATE

  • Saved 3 bytes, thanks to excellent advice from @Neil !

Can certainly be golfed further.

Golfed

S=(n,a,i=0)=>i<n-2?S(n,a,a.push(eval(a[i]+"+*-/"[i%4]+a[++i]))-2):a

Test

S=(n,a,i=0)=>i<n-2?S(n,a,a.push(eval(a[i]+"+*-/"[i%4]+a[++i]))-2):a

>S(8,[1,3]
Array [ 1, 3, 4, 12, -8, -1.5, -9.5, 14.25 ]

>S(5,[0,1])
Array [ 0, 1, 1, 1, 0 ]

>S(9,[1,0])
Array [ 1, 0, 1, 0, 1, 0, 1, 0, 1 ]

>S(25,[6,3])
Array [ 6, 3, 9, 27, -18, -1.5, -19.5, 29.25, -48.75, -0.6, ...]
zeppelin
  • 8.5k
  • 3
  • 21
  • 42