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

Stats:

CreatedAug 21, 2016
Warriors Trained117
Total Skips7
Total Code Submissions179
Total Times Completed63
JavaScript Completions63
Total Stars2
% of votes with a positive feedback rating70% of 38
Total "Very Satisfied" Votes22
Total "Somewhat Satisfied" Votes9
Total "Not Satisfied" Votes7
Total Rank Assessments37
Average Assessed Rank
7 kyu
Highest Assessed Rank
2 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • user6719857 Avatar
  • krnets Avatar
Ad