A hailstone sequence is considered long if its length is greater than its starting value. For example, the hailstone sequence in example 1 (5, 16, 8, 4, 2, 1) is considered long because its length (6) is greater than its starting value (5). The hailstone sequence in example 2 (8, 4, 2, 1) is not considered long because its length (4) is less than or equal to its starting value (8).

Write the method isLongSeq(int n), which returns true if the hailstone sequence starting with n is considered long and returns false otherwise. Assume that hailstoneLength works as intended, regardless of what you wrote in part (a). You must use hailstoneLength appropriately to receive full credit.

/** Returns true if the hailstone sequence that starts with n is considered long

* and false otherwise, as described in part (b).

* Precondition: n > 0

*/

public static boolean isLongSeq(int n)



Answer :

Other Questions