Write matlab code that will start with a positive integer

Assignment Help Computer Engineering
Reference no: EM132218404

Pick a number, any number (actually, make it a positive integer). Now, let's play a game. If your number is even, divide it by 2. If it is odd, multiply it by 3 and add 1.

Repeat this process with your new number. Repeat over and over again. Lothar Collatz in 1937 guessed that this process will always eventually end at the number 1. This is now known as the Collatz conjecture.

Write MATLAB code that will start with a positive integer and run through this process until a 1 is reached. Have your code print to the screen the number of iterations necessary to reach 1. As a test, your code should report that 68 iterations are necessary if we start with the number 2017.

How many iterations are needed if we start with the following numbers?

26

27 (Why does 27 take so much longer than 26 and 28? Just one of those things.)

28

670, 617, 279 (this is the longest the process takes for any starting number less than 1 billion)

Reference no: EM132218404

Questions Cloud

Write an expression that executes the loop body : Write an expression that executes the loop body as long as the user enters a non-negative number.
Which theorist fathered the principle : Based on your readings and research, develop a timeline of five key management theory/principle milestones over time. Please address the following questions.
Write some code that counts the number of times the value : Write some code that counts the number of times the value associated with student_id appears in the list associated with incompletes.
Identify the different target markets : Identify the different target markets and, using segmentation characteristics and any other applicable concepts, evaluate and explain your reasons.
Write matlab code that will start with a positive integer : Write MATLAB code that will start with a positive integer and run through this process until a 1 is reached.
Accept a string parameter representing a file name : Write a function named input_stats that accepts a string parameter representing a file name, then opens/reads that file's contents and prints information.
To which namespace does the file class belong : Which of the following methods could be used to retrieve a decimal value from a binary file? To which namespace does the File class belong?
Which method will be executed as a result : If a method in a subclass has the same signature as a method in the superclass, the subclass method overloads the superclass method.
What is the global cpi for each implementation : What is the global CPI for each implementation? Find the clock cycles required in both cases.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Discuss the high frequency conmponent of the input

An Fir filter of lengt 3 is defined by a symmetric impulse response I.E., h[0] = h[2]. Let the input to this filter be a sum of two cosine sequeces of angular.

  Derive the constant-property energy equation

Derive the conservation laws for axisymmetric flow in a pipe using control neglect body force work and the energy source.

  Develop a program for the pic

To develop a program for the PIC 16F84A using the MPLAB v8 IDE simulator software. The program is to convert your student number (10 ASCII characters), one character at a time, to 74210 code

  What is the purpose of the arp cache

Briefly describe the Address Resolution Protocol (ARP). What is the purpose of the ARP Cache? Complete following Hands-On Projects from the prescribed textbook.

  Define a second function to determine the estimated cost

Define a second function to determine the estimated cost of an item in a specified number of years, given the current price of the item and the inflation rate.

  How many colors can be displayed at any one time

How many distinct colors (including gray levels) can be displayed? How many colors can be displayed at any one time? What is the total memory size?

  Write a program that converts from twenty four-hour notation

Write a program that converts from 24-hour notation to 12-hour notation. For example, it should convert 14:25 to 2:25 P.M. The input is given as two integers.

  Develop a product service idea

After reviewing the assigned reading materials, complete the following activities: Describe the product/service including the benefits of using the product.

  Find the minimum number of multiplexer and gates

find the minimum number of multiplexer and gates to realize the given function.

  Create and initialise the main program objects

CP1300 SP51 2015 Assignment Details -create and initialise the main program objects, and to control program behaviour and

  Compare mpi scatter functions with your own scatter function

Write Myscatter programs and compare MPI scatter functions with your own scatter functions.

  Write a function that takes no input parameters

Write a function that takes no input parameters and returns nothing (void). Inside the function, create a variable of type int, and give that variable a value.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd