Series Pattern Detection

The goal of this challenge is to detect the pattern in a series of numbers, lets say 3 or more. For example, in the series

[3, 6, 9]

we know that it is simply adding 3 each time, and so, the computer should determine that the next number in the series should be 12.

[4, 16, 64]

in this case, each number is multiplied by 4, so the next number in the series is 256.

Your code should be able to detect arithmetic and geometric series, then be able to find the nth term in the series.