Programming Questions

Question & The hailstone sequence is one defined by

I'M =\

In - 1/ ? if In _ I is crell

`I'm - 1 + 1)

otherwise*

Eventually , for natural number values of a] , the hailstone sequence will converge to the cycle { } = 1 , `' * + 1 =

4, Ist ? _ _^its = ] . .... "This is not immediately obvious , but it does happen for all the inputs ] . .... I'll .

What I want you to consider in this question is the generalized hailstone defined by :

I'm - 1/ 2 if In _ I is even!

"In _ 1 + 6

otherwise

where a and & are integer valued in !'O..... 17; . For each of these 121 possible combinations of a and b, Find

out whether or not the sequence converges for all my values 1 . .... Logo . If the sequence does converge for

all these values , find out how many different cycles the sequence converges to . Once you have this dong , try

doing the same thing for the sequence where al , an , boy, big are in 10 . .... 10) :

if an - I mad } = "I'm -

"IIn _ 1 + by if an_ I mad` = 1

again _ It by if an _ I mad } = ?