#K84882. Fibonacci-like Sequence Checker
Fibonacci-like Sequence Checker
Fibonacci-like Sequence Checker
Given a sequence of integers, determine whether it forms a Fibonacci-like sequence. A Fibonacci-like sequence is defined as one in which every element (starting from the third) is the sum of its two preceding numbers. Note that the sequence must contain at least three numbers to be considered valid.
The input is provided via standard input. The first line contains an integer n representing the number of elements, and the second line contains n space-separated integers. The output should be True
if the sequence is Fibonacci-like and False
otherwise.
inputFormat
The first line contains a single integer n (n ≥ 0), which is the number of elements in the sequence. The second line contains n space-separated integers.
outputFormat
Output a single line with either True
or False
depending on whether the sequence is Fibonacci-like.
6
1 2 3 5 8 13
True
</p>