parent
a59b27e32e
commit
e1129f9075
@ -0,0 +1,3 @@
|
|||||||
|
console.log('x');
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|

|
||||||
|
|
||||||
|
# WDI-PANTHALASSA
|
||||||
|
|
||||||
|
---
|
||||||
|
Title: Arithmetic or Geometric <br>
|
||||||
|
Type: Morning Exercise <br>
|
||||||
|
Duration: 45 mins <br>
|
||||||
|
Creator: Thom Page <br>
|
||||||
|
Course: WDIr-Panthalassa<br>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 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]
|
||||||
|
```
|
||||||
Loading…
Reference in new issue