Hailstone N1 Write Python Function Hailstone Takes Int N1 Prints Hailstone Sequence Hailst Q37042104

hailstone (n1)

Write a python function “hailstone” that takes an int “n1” andprints the hailstone sequence.

Hailstone Numbers: This sequence takes the name hailstone as thenumbers generated bounce up and down. To generate the sequence,follow these rules:

a. If the number is odd multiply it by 3 and add 1

b. If the number is even, divide by two.

c. Repeat until you reach number 1

. Sample Inputs & Outputs

n1 = 3 -> 10, 5, 16, 8, 4, 2, 1

n1 = 6 -> 3, 10, 5, 16, 8, 4, 2, 1

n1 = 7 -> 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5,

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.