Skip to main content
1 of 2
xnor
  • 146.6k
  • 26
  • 279
  • 652

##Python 2, 55 bytes

def f(x,n):l=[1]*n;exec"print l[0];l=l[1:]+[sum(l)];"*x

Tracks a length-n window of the sequence in the list l, updated by appending the sum and removing the first element. Prints the first element each iteration for x iterations.

A different approach of storing all the elements and summing the last n values gave the same length (55).

def f(x,n):l=[1]*n;exec"l+=sum(l[-n:]),;"*x;print l[:x]
xnor
  • 146.6k
  • 26
  • 279
  • 652