Draft
Collatz Conjecture (Recursive)
Description:
The Collatz conjecture states that all numbers reach 1 using the Collatz sequence. The Collatz sequence goes like this: If the number is even then divide by 2; if the number is odd then multiply by 3 and add 1.
A simple sequence woud go like this:
For the number 3
1. 3 x 3 + 1 = 10
2. 10 / 2 = 5
3. 5 x 3 + 1 = 16
4. 16 / 2 = 8
5. 8 / 2 = 4
6. 4 / 2 = 2
7. 2 / 2 = 1
Create a function called collatzCount
that takes a number and returns the number of steps it takes to get back to 1. Although this problem can be solved without recursion, don't you think it would be more fun with?
You can expect that the number passed to collatzCount
will not be less than zero. You can only pass one argument to collatzCount
and you can only use that variable in the solution. No counting!
The test cases will expect for your solution to be recursive.
Recursion
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Aug 21, 2016 |
Warriors Trained | 117 |
Total Skips | 7 |
Total Code Submissions | 179 |
Total Times Completed | 63 |
JavaScript Completions | 63 |
Total Stars | 2 |
% of votes with a positive feedback rating | 70% of 38 |
Total "Very Satisfied" Votes | 22 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 7 |
Total Rank Assessments | 37 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 2 kyu |
Lowest Assessed Rank | 8 kyu |