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

 

konstans@stuy.edu all > hailLen
prev  |  next  |  chance

Calculate the length of a hailstone sequence starting with n. The hailstone sequence starts at any natural number n (the current number), and the next number is defined as 3n+1 when the current number is odd, or n/2 when n is even, and the stopping condition is always when n = 1. Sample sequences: 8 4 2 1 hailLen(8) -> 4 3 10 5 16 8 4 2 1 hailLen(3) -> 8


hailLen(1) → 1
hailLen(2) → 2
hailLen(3) → 8

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

def hailLen(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

Python Help

Copyright Nick Parlante 2017 - privacy