Problem 52669. Count the primes in Collatz sequences
Several Cody problems (21, 69, 42937, 44448, 44784, 52422) involve Collatz sequences. These start with a seed n. If n is odd, the next element is , and if n is even, the next element is . For example, if the seed is 3, then the sequence is 3, 10, 5, 16, 8, 4, 2, 1. The Collatz conjecture is that all of these sequences terminate at the value 1; that is, all seeds lead to terminating sequences.
This problem deals with the number of primes in the sequence. With a seed of 3, the number of primes is 3 (2, 3, 5).
Write a function to determine the numbers of primes in the sequences with seeds of 1 to the input number. See the test suite for banned terms and commands.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers15
Suggested Problems
-
4502 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
517 Solvers
-
Flip the main diagonal of a matrix
815 Solvers
-
941 Solvers
-
Count consecutive 0's in between values of 1
438 Solvers
More from this Author281
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!