This problem is related to Problem 42832.
Given positive integers x1, x2 and n, return a positive integer, y, which is the nth term in the Ulam sequence beginning with [x1 x2].
An Ulam sequence is an increasing sequence of positive integers, beginning with two arbitrary integers, x1 and x2. Every subsequent element is the smallest integer that can be expressed uniquely by the sum of any two distinct preceding elements. In other words, integers that can be expressed as sums of two distinct preceding elements in more than one way are excluded.
Assume n > 2.
Example:
x1 = 1
x2 = 2
n = 5
y = 6
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers23
Suggested Problems
-
Find the numeric mean of the prime numbers in a matrix.
9158 Solvers
-
Find the sum of the elements in the "second" diagonal
1204 Solvers
-
Flag largest magnitude swings as they occur
692 Solvers
-
Find and replaces spaces from a input string with *
172 Solvers
-
Compute LOG(1+X) in natural log
264 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!
This problem deserves to be is some of the groups :)