Problem 44340. Recaman Sequence - III
I want to create a Recaman sequence where there is a "1" in the n-th position. So from which integer should I start the Recaman sequence? If there are more than one starting integer that generates a sequence with a 1 in the n-th position, return the lowest one.
For example if I want to place the digit 1 in the 7th place in the sequence then I should start the sequence from six as follow;
seq = [6 5 3 6 2 7 1 8 16]
You can also start the sequence with 12 and obtain a series where there is a 1 in 7th position;
seq = [12 11 9 6 2 7 1]
Related Challenges :
- Recaman Sequence - I
- Recaman Sequence - II
- Recaman Sequence - III
Solution Stats
Problem Comments
-
12 Comments
Show
9 older comments
Alfonso Nieto-Castanon
on 23 Nov 2017
(otherwise a perfectly valid answer would be to use a seed = 1+n^2/2-n/2 which always results in a Recaman sequence with a 1 in the n-th position)
Mehmet OZC
on 23 Nov 2017
Thanks Alfonso, I tried to clarify the problem statement!
Gunther S
on 5 Jan 2018
leading solution is cheater solution: https://www.mathworks.com/matlabcentral/cody/problems/44340-recaman-sequence-iii/solutions/1391285
Solution Comments
Show commentsProblem Recent Solvers85
Suggested Problems
-
The Goldbach Conjecture, Part 2
2367 Solvers
-
Put two time series onto the same time basis
328 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
11940 Solvers
-
4681 Solvers
-
Integer sequence - 2 : Kolakoski sequence
168 Solvers
More from this Author92
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!