about | help | code help+videos | done | prefs |
The Collatz Conjecture (AGAIN) states that given natural numbers (1 or greater) that if a number is even you divide by 2 and if the number is odd, you multiply by THREE and add ONE. You repeat this process until you get to one. Write a RECURSIVE program to accept a natural number and count the number of iterations needed to get to ONE. Example 16->8, 8->4, 4->2, 2->1 - by counting the given number the number of steps is 5 CollatzResursive(1) → 1 CollatzResursive(2) → 2 CollatzResursive(4) → 3 ...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: 150
Copyright Nick Parlante 2017 - privacy