Background The Collatz conjecture (also known as the "3n+1 conjecture") is a conjecture in mathematics that concerns sequences defined by the following algorithm. Start with any positive integer n. Then each term, called a hailstone, is obtained from the previous term as follows: If the previous term is even, the next term is one half of the previous term If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what positive integer value you start with for n, the sequence will always reach 1. Assignment Description Write a program that prompts a user to enter a positive integer to begin the algorithm for the Collatz conjecture. The program will use a while loop to print each term (hailstone) and make repeated decisions to determine which transformation to apply each value of the sequence according to the conjecture algorithm until it reaches 1. Accept This Assignment B Purpose This assignment has the following purposes: • Practice analyzing a problem . Practice implementing a solution in Python • Practice using iteration structures to create repeated decision structures to control program execution flow Sample Output Enter a positive integer value: 17 The hailstones are: 52 26 16

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I am having issues on fixng a couple of errors I am recieving an my lines 16 and maybe 17 aswell.

Background
The Collatz conjecture (also known as the "3n+1 conjecture") is a conjecture in mathematics that concerns sequences defined by the following algorithm.
Start with any positive integer n. Then each term, called a hailstone, is obtained from
the previous term as follows: If the previous term is even, the next term is one half of the previous term.
If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture
is that no matter what positive integer value you start with for n, the sequence will always reach 1.
Assignment Description
Write a program that prompts a user to enter a positive integer to begin the algorithm for the Collatz conjecture. The program will use a while loop to print each term (hailstone) and make repeated decisions to determine which transformation to
apply to each value of the sequence according to the conjecture algorithm until it reaches 1.
Accept This Assignment B
Purpose
This assignment has the following purposes:
• Practice analyzing a problem
• Practice implementing a solution in Python
• Practice using iteration structures to create repeated decision structures to control program execution flow
Sample Output
Enter a positive integer value: 17
The hailstones are:
52
13
40
10
Transcribed Image Text:Background The Collatz conjecture (also known as the "3n+1 conjecture") is a conjecture in mathematics that concerns sequences defined by the following algorithm. Start with any positive integer n. Then each term, called a hailstone, is obtained from the previous term as follows: If the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what positive integer value you start with for n, the sequence will always reach 1. Assignment Description Write a program that prompts a user to enter a positive integer to begin the algorithm for the Collatz conjecture. The program will use a while loop to print each term (hailstone) and make repeated decisions to determine which transformation to apply to each value of the sequence according to the conjecture algorithm until it reaches 1. Accept This Assignment B Purpose This assignment has the following purposes: • Practice analyzing a problem • Practice implementing a solution in Python • Practice using iteration structures to create repeated decision structures to control program execution flow Sample Output Enter a positive integer value: 17 The hailstones are: 52 13 40 10
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
个
# Enter the positive number
|n = int(input("\nEnter a positive integer value: "))
print("The hailstones are: ")
while n != 1:
← → TA 2014
A
A
A
부
# if n is even
if n%2 == 0:
#if n is even, divides n/2
n = int(n/2)
else:
#if n is odd, makes n = 3n+1
n = (3*n) +1
#prints n
A print (n)
while n = 1 > if n%2 == 0
Run:
Lab4 X
if __name__ == "__main__":
main ()
n = int(input("\nEnter a positive integer value: "))
A
IndentationError: expected an indented block
", line 17
Transcribed Image Text:15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 个 # Enter the positive number |n = int(input("\nEnter a positive integer value: ")) print("The hailstones are: ") while n != 1: ← → TA 2014 A A A 부 # if n is even if n%2 == 0: #if n is even, divides n/2 n = int(n/2) else: #if n is odd, makes n = 3n+1 n = (3*n) +1 #prints n A print (n) while n = 1 > if n%2 == 0 Run: Lab4 X if __name__ == "__main__": main () n = int(input("\nEnter a positive integer value: ")) A IndentationError: expected an indented block ", line 17
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Merge Sort
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education