Problem 57492. Compute the Tetris sequence

In the Tetris sequence, which starts with a 1, the next term is the smallest positive integer not already in the sequence that has no common 1-bits with the previous term. The first five terms are 1, 2, 4, 3, and 8 because the binary expansions 0001, 0010, 0100, 0011, and 1000 have no common ones among consecutive terms, and they are the smallest numbers with that property not already in the sequence.
The discussion of this sequence involves odd gaps in the plot of the terms a(n) (say) as a function of their position n in the sequence. A plot of a(n+1) vs. a(n) (below) makes one think of the Sierpinski gasket. Neil J.A. Sloane uses this resemblance to propose using “facial recognition” to connect sequences.
Write a function to compute the nth term of the Tetris sequence.

Solution Stats

87.5% Correct | 12.5% Incorrect
Last Solution submitted on Jan 06, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

More from this Author249

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!