Question: With C programming language Create a function (use an informative function name) that prints out and counts the length of the Collatz sequence for the

 With C programming language Create a function (use an informative function

With C programming language

Create a function (use an informative function name) that prints out and counts the length of the Collatz sequence for the random number you just generated. Collatz sequence is iterated for positive integers like this: i. n-> n/2 (so if n is even (=parillinen in Finnish), divide it by two) ii. n-> 3n+ 1 (so if n is odd (=pariton in Finnish), triple it and add one) iii. For example, for number 13 the sequence (and output print) is like this (sequence starts from 13 and ends when it reaches 1): . Collatz sequence for 13 is: 13-40 - 20-10-5-16-8-4-2-1 . Length of the sequence is: 10 iv. Notice that Collatz length includes the given number itself and also number 1 (where the sequence ends) V. Remember that random number can also be 0 or 1. Test both carefully

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!