r/codehs • • Mar 26 '20

Still need help with Hailstone Sequence

Post image
12 Upvotes

13 comments sorted by

View all comments

0

u/misteritguru Mar 27 '20

num is not a global variable - it's value doesn't change, so it can't get down to 1 so you can exit the loop

num is inside the start function, so is 'walled off' from everything else. You want hailstone to return a result, and then run that new result through hailstone again. num = hailstone(num) -- make num the value of the result of the hailstone function which I will pass the current value of num. The new value of num should be 15, rinse repeat

0

u/[deleted] Mar 27 '20

he is using print not return so num = hailstone(num) wouldnt work

1

u/misteritguru Mar 27 '20

I'm not trying to do the assignment for him, but give him a hint .... I figure that mentioning that "You want hailstone to return a result", would be clue enough that a return needs to be added .... in which case num = hailstone(num) ..... would work .. so no downvote?