Husk, 5 66 5 bytes
€ḣ¹tẊ€¹tẊ-
Outputs 1
for truthy (it's a fibonacci-like sequence), any other non-negative integer for falsy (it isn't a fibonacci-like sequence).
Get the pairwise differences (Ẋ-
), remove the first one (t
), and check if this is ancheck if this is an ordered sublist of the input one offind the prefixesindex of this sublist in the input (€ḣ¹
), or 0
if not present.
Of course, it needs to be a prefix of the input (rather than a sublist at any other position), but I think this should be ensured since the input is increasing.
Edit: the fact that the input is increasing does not ensure that sublists must be prefixes (consider 1 2 4
with difference sublist 2
), so we need to specifycheck this directly, atby requiring that the costindex of 1-bytethe sublist must be 1
.