Problem 52669. Count the primes in Collatz sequences
Solution Stats
Problem Comments
-
4 Comments
I notice that p=isprime(x) can be a lot slower than p=ismember(x,primes(max(x))); for x=1:1e7, the former takes about 100 seconds and the latter takes about 0.1 seconds.
Nice observation. I'll keep that one in mind.
Actually for the first case (seed n = 1), the answer should be 1 and not 0, since the corresponding Collatz sequence is the loop (1, 4, 2), should'nt it be ?
Ok I suppose we don't count the special case of this infinite loop since we do have to stop the sequence at a point ! (1)
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
1964 Solvers
-
983 Solvers
-
Find out missing number from a vector of 9 elements
310 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
390 Solvers
-
Find x rows where the sum of the numbers is the maximum
556 Solvers
More from this Author314
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!