id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

andersoniii.edwin@cusd80.com week8 > CollatzNumbers
prev  |  next  |  chance

The Collatz Conjecture 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 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


CollatzNumbers(1) → 1
CollatzNumbers(2) → 2
CollatzNumbers(4) → 3

...Save, Compile, Run (ctrl-enter)

public int CollatzNumbers(int a){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 100 Post-solution available

Copyright Nick Parlante 2017 - privacy