Write a function parta which prints a sequence of numbers

Assignment Help Computer Engineering
Reference no: EM132164462

Using C++

Do not make use of any variables in your answers to this question.

Only consider positive numbers.

Part A. Write a function parta(int x) which prints a sequence of numbers starting with x itself, and counting down, but stopping after it first prints a number that is divisible by 11. For example, parta(30) should print:

30 29 28 27 26 25 24 23 22

Part B. Write another function partb(int x) which does not print anything, but instead returns as its result the length of the sequence that parta(x) would have printed.

For example, const int n = partb(30) should set n to 9, because parta(30) prints 9 numbers.

Part C. There is a mysterious mathematical thing called a Collatz Sequence. It can start with any number N. If N is odd, the rest of the sequence is the collatz sequence starting from 3*N+1, but if N is even, the rest of the sequence is the collatz sequence starting from N/2. The sequence stops after it reaches 1.

Write a function partc(int N) which prints the entire Collatz sequence starting from N.

For example, partc(24) should print:

24 12 6 3 10 5 16 8 4 2 1

Part D. Write another function partd(int N) which returns as its result the length of the Collatz sequence that starts with N.

For example, partd(24) is equal to 11, because as you can see from the previous example, the Collatz sequence starting from 24 consists of 11 numbers.

Reference no: EM132164462

Questions Cloud

Find the probability that x assumes a value : If the mean is 26and the standard deviation is 7, find the probability that x assumes a value between 30.7 and 61.0
Write a function that will read a body of text and count : Write a function that will read a body of text and count the number of nonblank characters and the number of words in a paragraph.
Create a password class that has one attribute : Using C++ Create a password class that has one attribute (char password[SIZE]. Implement the class to fill in the password and display it.
What is the value of the appropriate test statistic : Assuming that the population variances are not equal, what is the value of the appropriate test statistic?
Write a function parta which prints a sequence of numbers : Write a function parta(int x) which prints a sequence of numbers starting with x itself, and counting down, but stopping after it first prints a number.
Rejecting the null hypothesis will make the manufacturer : Hint: Rejecting the null hypothesis will make the manufacturer happy as it will show that standards are being met.
Test the code for all of the given functionality : Memory management should be done dynamically using the appropriate new operator in the constructor and the delete operator in the destructor.
Define the rejection region for test : How would you define the rejection region for this test at a = .001?
Hormone therapy developed cancer : A group conducted a randomized experiment to see if hormone therapy was helpful for? post-menopausal women.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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