# Write a program to print out Collatz sequence for a user-supplied number. Prompt the user for a positive integer which will become the first number in the sequence. Next number in the sequence is derived as follows If previous number is odd, the next number is 3 times the previous, plus 1. If previous number is even

Write a program to print out Collatz sequence for a user-supplied number. Prompt the user for a positive integer which will become the first number in the sequence. Next number in the sequence is derived as follows: If previous number is odd, the next number is 3 times the previous, plus 1. If previous number is even, the next number is half of the previous

According to Collatz proposition, the sequence ultimately reaches 1 no matter what the starting number is.

Your program should print out all numbers in the sequence down to 1. At the end, display number of iterations it took to arrive at 1, and average of all values in sequence. For prettier output, insert a line break after printing every five numbers, align the numbers in columns and format the average value to two decimal places.

After printing a Collatz sequence, your program should ask the user if they want to print out another sequence. The loop will continue until user decides to quit.

Review the sample run below to clearly understand all requirements.

Enter a positive number, or zero to quit: 57

172 86 43 130
65 196 98 49 148
74 37 112 56 28
14 7 22 11 34
17 52 26 13 40
20 10 5 16 8
4 2 1
It took 32 iterations to arrive at 1. The average value is 51.66

Enter the next positive number, or zero to quit: 11

11 34 17 52 26
13 40 20 10 5
16 8 4 2 1
It took 14 iterations to arrive at 1.

The average value is 18.50

Enter the next positive number, or zero to quit: 0

Have a nice day!

Your submission must consist of following tasks: Task 1 Draw a flowchart that presents the steps of the algorithm required to perform the task specified. You can draw the flowcharts with a pen/pencil on a piece of paper and scan it for submission, as long as the handwriting is clear and legible. However, it is strongly recommended to draw flowcharts using a drawing software. Here are links to some free drawing tools

Draw.io Lucidchart with an education account (register using your_csu_id@postoffice.csu.edu.au)

yEd Graph Editor

Pencil Project

Pages (550 words)
Approximate price: -

Quality Research Papers

We always make sure that our academic writers follow all your instructions precisely. You can choose your academic level and we will assign a writer who has a respective degree.

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document.

On time Delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. Otherwise a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Whether you have an urgent deadline or those that have time. You can take some time and relax after trusting us with your paper. We make sure that we conduct the academic writing services diligently.

## Essay Writing Service

Among the wide variety of academic work, essay writing is one of the simplest a student can ever come across. Usually, it is a task which students encounter and learn how to write whilst in high school. However, the case is quite different when it comes to university and college.

Term Paper Writing

Are you looking for an online writing firm that can offer you reliable custom term paper writing help? Is your wish and desire to get someone who can guide you throughout the process of writing term papers? If yes, then you have come to the right place.

Coursework Writing Help

Coursework is essential for every student in order to graduate from college. However, most of it is deadline-centric, and that becomes a challenge to most learners. With the amount of work, learners are receiving every day, finding time to work on every task is not easy.

Online Homework Help

Online homework help services are an answer to every challenge that students go through. Despite the difference in the needs and levels of learning, all students can benefit from these services. Acemyhomework is one of the best online homework help service companies you can find on the internet.