minHailstoneValue
Category: Programming
Author: Stuart Reges
Book Chapter: 4.1
Problem: minHailstoneValue
Write a method minHailstoneValue that takes integers n and m as parameters and that returns the minimum value in a hailstone sequence of length m that begins with n. In a hailstone sequence, each value x is followed either by: (3x + 1) if x is odd (x/2) if x is even For example, if we start with 7 and we construct a sequence of length 10, we get: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20 In this case, the minimum value in the sequence is 7 (the number we started with). Therefore, the following call: minHailstoneValue(7, 10) should return 7. If we instead construct a sequence of length 20, we get: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1 In this case, the minimum value in the sequence is 1. Therefore, the call: minHailstoneValue(7, 20) should return 1. You may assume that both integers passed to your method are greater than 0. Write your solution to minHailstoneValue below.