6 kyu
T.T.T.37: Reversal of Collatz
64 of 113myjinxin2015
Description:
Description
Do you know Collatz conjecture? Click here, You can read some details..
Given the following algorithm (Collatz conjecture):
If number x is even, x = x / 2
else if x is odd, x = x * 3 + 1
Find all the possible numbers(x) which resolve to a specified number (y) when the algorithm is applied a specified number of times (n).
Sort the results in ascending order.
For example:
Find all the possible numbers which resolve to 1 (y = 1) after 5 applications of the algorithm (n = 5). (in accordance with the rules of the Collatz conjecture)
reversalCollatz(5,1) === [4,5,32]
Because:
4 -> 2 -> 1 -> 4 -> 2 -> 1
5 -> 16 -> 8 -> 4 -> 2 -> 1
32 -> 16 -> 8 -> 4 -> 2 -> 1
More Examples
reversalCollatz(5,1) === [4,5,32]
reversalCollatz(3,12) === [48]
reversalCollatz(4,7) === [9,56]
Puzzles
Games
Similar Kata:
Stats:
Created | Aug 15, 2016 |
Published | Aug 15, 2016 |
Warriors Trained | 471 |
Total Skips | 56 |
Total Code Submissions | 458 |
Total Times Completed | 113 |
JavaScript Completions | 64 |
Python Completions | 57 |
Total Stars | 8 |
% of votes with a positive feedback rating | 97% of 46 |
Total "Very Satisfied" Votes | 43 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |