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

 

andersoniii.edwin@cusd80.com > CollatzResursive
prev  |  next  |  chance

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)

public int CollatzResursive(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: 150

Copyright Nick Parlante 2017 - privacy