A few problems on Cody involve sieving. For example, Cody Problem 45367 involves the famous Sieve of Eratosthenes. CP 50811 uses the sieve of Flavius Josephus, and CP 50913 uses the golden sieve.
This problem uses a process that I will call the whyphi sieve:
- Make a list x of integers 1, 2, 3,…
- Remove the first term. That is, delete x(1).
- Renumber the terms.
- Delete x(2) and x(2+1)
- Renumber the terms.
- Delete x(3), x(3+2), and x(3+2+1).
- Continue renumbering and deleting terms in this way.
Write a function to compute the nth term of this sequence.
Solution Stats
Solution Comments
Show comments
Loading...
Problem Recent Solvers6
Suggested Problems
-
3094 Solvers
-
Set some matrix elements to zero
642 Solvers
-
Rotate input square matrix 90 degrees CCW without rot90
698 Solvers
-
327 Solvers
-
Create matrix of replicated elements
402 Solvers
More from this Author328
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!