4.15 LAB: Hailstone sequence Given a positive integer n, the following rules will always create a sequence that ends with 1, called the hailstone sequence: If n is even, divide it by 2 If n is odd, multiply it by 3 and add 1 (i.e. 3n +1) Continue until n is 1 Write a program that reads an integer as input and prints the hailstone sequence starting with the integer entered. Format the output so that ten integers, each separated by a tab character (\t), are printed per line. The output format can be achieved as follows:
print(n, end='\t') Ex: If the input is: 25 the output is: 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1

Respuesta :

The program to illustrate the integer will be:

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

i = 1

print(n,"\t",end = "")

while(n != 1):

   if(n%2 == 0):

       n = n/2

   else:

       n = 3*n + 1  

   print(n,'\t',end = "")

   i = i+1  

   if(i == 10):

      i = 0

      print("")

What is a program?

The process of creating instructions for computers to follow is known as computer programming. The code, also referred to as the instructions, is written in a programming language that the computer can comprehend and use to carry out a task or address a problem.

One can benefit from coding because it boosts their confidence and it equips one with the practical abilities like creativity, problem-solving, and perseverance.

Learn more about program on:

https://brainly.com/question/1538272

#SPJ1