Solve a basic sequence pattern: 2, 6, 12, 20, X. What is X?
Implement next_term(sequence) to return the next value in a sequence following this pattern. The input is a list of integers beginning with 2, 6, 12, 20, and the output is one integer. For the given sequence, the expected result is 30.
def next_term(sequence):