Problem 50913. Compute the nth term from the golden sieve
Cody Problem 45367 involved the Sieve of Eratosthenes, and Cody Problem 50811 involved the Sieve of Flavius Josephus. To apply the golden sieve, start with the natural numbers and at the nth step, take the sequence, which we will call a, and delete the term in the position.
In the first step, delete the term in the position to get 2, 3, 4, 5, 6, 7,…Then in the second step, delete the term in the position (i.e., 4) to get 2, 3, 5, 6, 7, 8, 9,…In the third step, delete the term in the position (i.e., 7) to get 2, 3, 5, 6, 8, 9, 10,…Et cetera.
Write a function that returns the nth term in the sequence after an infinite number of steps.
Solution Stats
Problem Comments
-
3 Comments
Solution Comments
Show commentsProblem Recent Solvers17
Suggested Problems
-
Find common elements in matrix rows
2537 Solvers
-
Project Euler: Problem 3, Largest prime factor
1348 Solvers
-
How long do each of the stages of the rocket take to burn?
259 Solvers
-
310 Solvers
-
Spot the First Occurrence of 5
415 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!