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

 

bryce.hulett@hotmail.com > hailStone
prev  |  next  |  chance

The Hailstone sequence of numbers can be generated from a starting positive integer, n by: If n is 1 then the sequence ends. If n is even then the next n of the sequence = n/2. If n is odd then the next n of the sequence = (3 * n) + 1. Return this sequence as a List given some n.


hailStone(1) → [1]
hailStone(6) → [6, 3, 10, 5, 16, 8, 4, 2, 1]
hailStone(4) → [4, 2, 1]

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

public List hailStone(int n){ }

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: 200 Post-solution available

Copyright Nick Parlante 2017 - privacy