Problem 42839. Identify the sequence
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
Show
2 older comments
Tim
on 5 May 2016
Test case 11 is still incorrect.
Jean-Marie Sainthillier
on 9 May 2016
x = [i -2 -4i 8 16i] is an arithmetic serie ?
HH
on 27 May 2016
Test case 11 fixed. Thanks.
Solution Comments
Show commentsProblem Recent Solvers26
Suggested Problems
-
1958 Solvers
-
3043 Solvers
-
Remove the small words from a list of words.
1540 Solvers
-
middleAsColumn: Return all but first and last element as a column vector
616 Solvers
-
Circular Primes (based on Project Euler, problem 35)
575 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!