We often solve fun number pattern riddles on here. Let's see if we can write a program to solve basic ones. Today's problem is to create a program that determines if an array contains an arithmetic or geometric sequence (no sorting required). Arithmetic patterns always change by the same value 2,4,6. Geometric patterns always change by the same ratio 8,4,2. If the pattern doesn't match either algorithm then just return "no pattern".

For bonus points figure out if a sequence has a plus 1 increase pattern (2,4,7,11).

## Comments:

Driphter - 4 years ago

Clojure!

reply permalink