Given a row vector, x, return 1 if it is an arithmetic series, or 2 if it is a geometric series. If it is neither, return 0.
Example 1:
x = 1:8
y = 1
Example 2:
x = 2^(1:8)
y = 2
Example 3:
x = [1 1 2 3 5 8 13 21 34]
y = 0
Solution Stats
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers29
Suggested Problems
-
Find the sum of the elements in the "second" diagonal
1204 Solvers
-
Calculate the area of a triangle between three points
3417 Solvers
-
Create a vector whose elements depend on the previous element
786 Solvers
-
150 Solvers
-
Replace values out of an interval with the lower or upper values
71 Solvers
More from this Author45
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Perhaps a better strategy is to make a new problem instead of frequently re-scoring due to incremental changes. BTW, the newly added last test case (#11) should return 2, not 1.
Yes, Test 11 -> 2
Test case 11 is still incorrect.
x = [i -2 -4i 8 16i] is an arithmetic serie ?
Test case 11 fixed. Thanks.