about | help | code help+videos | done | prefs |
The Collatz Conjecture in mathematics is about a recursive mathematical formula and the (believed) final result of recursively applying the formula. A Collatz sequence (or orbit) describes the specific values that are landed upon in this recursive process. So what is the specific recursive process? Here it is: Let n be a positive integer. n=1 is the base-case. No further calculations are needed. if n is even, your new number is n/2. if n is odd, your new number is 3n+1. For example, if you start with 14, the Collatz sequence (or orbit) is: 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 To make things easier, we will return a string with spaces between each number AND a space at the end. So, if your initial number 'n' is 14 you will return: "14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 " It is believed that following this process starting with any positive integer will eventually lead to 1. That is to say that it is believed that this process will never get "trapped" in some kind of repetitive loop. This seemingly simple conjecture has yet to be proven, although it is known to be true for all integers less than an extremely large number with over 1000 digits! quiz2023_02_28_P1SLHL_sequenceCollatz(14) → "14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 " quiz2023_02_28_P1SLHL_sequenceCollatz(16) → "16 8 4 2 1 " quiz2023_02_28_P1SLHL_sequenceCollatz(4) → "4 2 1 " ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy