human
Hailstone Numbers | function to print hailstone numbers and to calculate the number of steps required.
N is initially 1..
N is reduced to 1..
If N is Even ..
N is Odd ..
Driver Code.
Function to generate Hailstone Numbers.
Output : Number of Steps"
Solution in Python:
assistant
#Here is code to hailstone Numbers and the other steps required.
 def HailstoneNumbers ( N , c ) :
	print ( N , end = " ▁ " )
	if ( N == 1 and c == 0 ) :
		return c
	elif ( N == 1 and c != 0 ) :
		c = c + 1
	elif ( N % 2 == 0 ) :
		c = c + 1
		c = HailstoneNumbers ( int ( N / 2 ) , c )
	elif ( N % 2 != 0 ) :
		c = c + 1
		c = HailstoneNumbers ( 3 * N + 1 , c )
	return c
N = 7
x = HailstoneNumbers ( N , 0 )
print ( " Number of Steps :   " , x )