Problem Description The hailstone sequence is defined as the integer sequence that results from manipulating a positive integer value n as follows: • If n is even, divide it by 2 (using floor division) • If n is odd, multiply it by 3 and then add 1 Repeat this process until you reach 1. For example, starting with n = 5, we get the sequence 5, 16, 8, 4, 2, 1. If n is 6, we get the sequence 6, 3, 10, 5, 16, 8, 4, 2, 1. If n is 7, we get 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. If n is 8, we get the sequence 8, 4, 2, 1. As far as anyone can tell, this process will eventually reach 1 for any starting value, although mathematicians have been unable to formally prove this property as of yet. a. Write a Python function named hail () that takes a single integer argument. hail() should print out the sequence of numbers generated by applying the process above to the function parameter. This function does not return any value.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question
Problem Description
The hailstone sequence is defined as the integer sequence that results from manipulating a positive
integer value n as follows:
If n is even, divide it by 2 (using floor division)
• If n is odd, multiply it by 3 and then add 1
Repeat this process until you reach 1.
For example, starting with n = 5, we get the sequence 5, 16, 8, 4, 2, 1.
If n is 6, we get the sequence 6, 3, 10, 5, 16, 8, 4, 2, 1.
If n is 7, we get 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1.
If n is 8, we get the sequence 8, 4, 2, 1.
As far as anyone can tell, this process will eventually reach 1 for any starting value, although
mathematicians have been unable to formally prove this property as of yet.
a. Write a Python function named hail () that takes a single integer argument. hail() should
print out the sequence of numbers generated by applying the process above to the function
parameter. This function does not return any value.
Transcribed Image Text:Problem Description The hailstone sequence is defined as the integer sequence that results from manipulating a positive integer value n as follows: If n is even, divide it by 2 (using floor division) • If n is odd, multiply it by 3 and then add 1 Repeat this process until you reach 1. For example, starting with n = 5, we get the sequence 5, 16, 8, 4, 2, 1. If n is 6, we get the sequence 6, 3, 10, 5, 16, 8, 4, 2, 1. If n is 7, we get 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. If n is 8, we get the sequence 8, 4, 2, 1. As far as anyone can tell, this process will eventually reach 1 for any starting value, although mathematicians have been unable to formally prove this property as of yet. a. Write a Python function named hail () that takes a single integer argument. hail() should print out the sequence of numbers generated by applying the process above to the function parameter. This function does not return any value.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Multithreaded Algorithms
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr