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

Stats:

CreatedAug 15, 2016
PublishedAug 15, 2016
Warriors Trained471
Total Skips56
Total Code Submissions458
Total Times Completed113
JavaScript Completions64
Python Completions57
Total Stars8
% of votes with a positive feedback rating97% of 46
Total "Very Satisfied" Votes43
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • kazk Avatar
  • ZED.CWT Avatar
  • mauro-1 Avatar
Ad