Problem 57720. The Yellowstone Permutation
The Yellowstone Permutation is a sequence of positive integers, defined by the following rules:
- No term is repeated.
- Given n terms, the next term, a(n+1), is always the smallest possible integer.
- Every term, a(n), must be relatively prime to the previous term, a(n-1).
- Every term, a(n), must have a common divisor greater than 1 with the term before the previous, a(n-2).
The first three terms of the sequence, after which we start applying the rules, are [1 2 3].
Given a positive integer, n, return the n-th term of the sequence, a(n).
Example:
n = 4;
a = 4
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers7
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
48172 Solvers
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15467 Solvers
-
Remove the two elements next to NaN value
645 Solvers
-
mathematics , probability problem
63 Solvers
-
How long do each of the stages of the rocket take to burn?
272 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!