Problem 58498. Compute the Sisyphus sequence
Solution Stats
Problem Comments

3 Comments
For the case flag=false, what does "next largest prime" mean? I don't understand how you get 1, 3, 8, 4, 2, 1, 4, 2, 1, 8, 4, 2, 1, 12, 6, 3, 16, 8, 4, 2, 1….
I changed it to "next largest unused prime". That is, once you use a prime, delete it from the list. Start at 1, which is odd. The NLUP is 2, so the next term is 3. Then the NLUP is 5, so the next term is 8. Then 4, 2, 1. Then the NLUP is 3. Then 4, 2, 1. Then NLUP = 7, etc. Does that help?
I see nowbecause a(2)=3 you add p=5 instead of p=3, and then go back and use p=3 the next time. It seems like this is the only time this happensfrom then on the next largest unused prime is always the next prime.
Solution Comments
Show commentsProblem Recent Solvers5
Suggested Problems

570 Solvers

Back to basics 12  Input Arguments
594 Solvers

Return a list sorted by number of consecutive occurrences
358 Solvers

Implement a bubble sort technique and output the number of swaps required
281 Solvers

93 Solvers
More from this Author272
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!