Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. (14) The routine 3N+1* follows these rules: If a given N is odd, multiply it by 3 and add 1. If the given N

image text in transcribed
4. (14) The routine "3N+1* follows these rules: If a given N is odd, multiply it by 3 and add 1. If the given N is even, divide it by 2. Repeat this rule on the new value until you get 1, if ever. For example, start with the number 3: because 3 is odd, we multiply by 3 and add 1 giving us 10. 10 is even so we divide it by 2, giving us 5. 5 is odd so we multiply by 3 and add one, giving us 8. We divide 8 (even) by two giving 4. We divide 4 (even) by two giving 2. We divide 2 (even) by 2 to give us 1. Once we have one, we stop. This example took six iterations to get to one. Every value of N that anyone has ever checked eventually leads to 1, but it is an open mathematical problem (known as the Collatz conjecture) whether every value of N eventually leads to 1 Run your program repeatedly for initial integer N values from 2 to 100. Hint: Use a A. Plot the number of steps taken to get to 1 against the starting value of N B. Plot the maximum value before getting to 1 against the starting value of N C. Plot the maximum value versus the number of steps (include proper labels). for loop around your function in HW3A. (include proper labels). Use a log-log scale. (include proper labels). Use a log-log scale. Use a log-log scale. Is there a general trend between the two values

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions