Problem 54660. Generate the Figure-Figure sequence
After discussing Scott Kim’s FIGURE-FIGURE Figure (below) in Gödel, Escher, Bach, Douglas Hofstadter introduced an integer sequence a (say) generated by this rule: it starts with 1, and each later term equals the sum of the previous term in a and the latest term that is not already contained the sequence a.
For example, the second term in the sequence is 3 because the first number not in the sequence is 2, and 1+2 = 3. The third term is 7 because the next term not in a is 4 and 3+4 = 7.
Not only is the complement of the sequence a equal to the differences between the terms, but together the two sequences contain all positive integers.
Write a function that returns the nth term of the sequence.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers5
Suggested Problems
-
Return a list sorted by number of occurrences
2640 Solvers
-
2321 Solvers
-
129 Solvers
-
Make a random, non-repeating vector.
8334 Solvers
-
607 Solvers
More from this Author249
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!