You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
965 B
965 B
WDI-PANTHALASSA
Title: Arithmetic or Geometric
Type: Morning Exercise
Duration: 45 mins
Creator: Thom Page
Course: WDIr-Panthalassa
Arithmetic or Geometric sequence?
Write a method arith_geo that takes an array of numbers and returns the string "Arithmetic" if the sequence in the array follows an arithmetic pattern, or returns "Geometric" if it follows a geometric pattern. If the sequence doesn't follow either pattern return -1.
An arithmetic sequence is one where the difference between each of the numbers is consistent, eg. the difference between each number is 5.
Whereas in a geometric sequence, each term after the first is multiplied by some constant or common ratio.
Arithmetic example: [2, 4, 6, 8]
Arithmetic example: [20, 28, 36, 44]
Geometric example: [2, 6, 18, 54]
Geometric example: [6, 12, 24, 48]
