Next element in arithmetic sequence
Problem to find next arithmetic sequence in given sequence.
Example-1:
Input : n = [ 1, 3, 5, 7] Output : 9
Example-2:
Input : n = [ 10, 8, 6] Output : 4
Solution
n = [ 1, 3, 5, 7] a = n[-1] + (n[-1]-n[-2]) print(a)
Output
9