Westonci.ca is the ultimate Q&A platform, offering detailed and reliable answers from a knowledgeable community. Explore comprehensive solutions to your questions from a wide range of professionals on our user-friendly platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

Overview Write a program that reads an integer from the user and then prints the Hailstone sequence starting from that number "What is the hailstone sequence?" you might ask. Well, there are two rules: • If n is even, then divide it by 2 • If n is odd, then multiply it by 3 and add 1 Continue this sequence until you hit the number 1.​

Overview Write A Program That Reads An Integer From The User And Then Prints The Hailstone Sequence Starting From That Number What Is The Hailstone Sequence You class=

Sagot :

n=int(input("Enter number: "))

while n != 1:

   print(n)

   if n%2==0:

       n//= 2

   else:

       n = (n*3)+1

print(n)

I wrote my code in python 3.8. If you want to print the 1, keep the last line of code otherwise delete it.