N-bonacci from a Seed
An N-bonacci sequence is a Fibonacci-like sequence where the N previous terms are added to get the next term. The Fibonacci series is a 2-bonacci sequence.
Given a list of integers L
of length l
and an integer n
, output the first n
digits of the l
-bonacci sequence starting with the sequence L
.
Input
Input is a list, array, delimited string, stream, etc of integers, and an integer. Input is flexible, provided L
and n
are separable. It is guaranteed that 0 <= n <=>= l0
, and l >= 1
.
Output
Output the first n
digits of the l
-bonacci sequence starting with L
. Output is flexible here also: a list, array, string, stream, etc.
Samples:
[1,1], 5 --> 1, 1, 2, 3, 5
[0,1,2], 1 --> 0
[10,1,-1], 10 --> 10, 1, -1, 10, 10, 19, 39, 68, 126, 233
[-1,0,1], 0 --> //no output, or empty output
[-1], 3 --> -1, -1, -1
[-1,-2,1,0], 9 --> -1, -2, 1, 0, -2, -3, -4, -9, -15
This is code-golf, so smallest in bytes wins.