EDIT: I will be accepting an answer Monday, 2/15/2016. May the bytes be ever in your favor!
In his "Print the N-Bonacci Sequence" challenge, @DJMcGoathem describes the N-bonacci sequences, wherein the previous N numbers are summed, instead of the traditional 2 of the Fibonacci sequence (said to be the "duonacci sequence"). He then asked to take two inputs, X and N, then output the Xth N-nacci number.
I propose the opposite.
Given a sequence, output which N-nacci sequence it is a subset of. I say "subset of" because:
- A) these sequences are infinite
- B) if given the start of the sequence, you could just count the number of leading 1s
In the case that it could belong to multiple N-nacci sequences, chose the lowest one.
In the case that it does not belong to any N-nacci sequence, then your program may do anything other than print something that could be mistaken for output. These behaviors include (but are not limited to): infinite loop, error, crash, delete itself (*cough cough* vigil *cough cough*), or create a black hole (as long as this black hole does not produce anything that could be mistaken for valid output).
For the sake of this challenge, these sequences start with 1. This means any N-nacci sequence starts with N ones. Furthermore, N must be a positive integer. So no -1-nacci, etc.
Test cases:
1,1,1 -> 1
49, 97 -> 7
55, 89, 144 -> 2
1 -> 1
6765 -> 2
12, 23, 45, 89 -> 12
100, 199 -> 100
create a black hole (as long as this black hole does not produce anything that could be mistaken for valid output).
My, the spirals of the black hole are converging to the golden ratio! It must be valid output for a duoacci sequence! \$\endgroup\$