Question: C++ please Project 3: Collatz Sequences (COL] Textbook Section: 4.23 Se t Up: In a Collatz sequence, all of its terms are positive integers which
Project 3: Collatz Sequences (COL] Textbook Section: 4.23 Se t Up: In a Collatz sequence, all of its terms are positive integers which satisfy the following recursive formula a.. an-1 f an-1 is even an3an-1 +1 if an-1 is odd For example, if the first term in the sequence is au -13, then the recursive formula gives the corresponding Collatz sequence: 1340-+ 2010516-8-1-2-1 Note, it is thought that all Collatz sequences end with 1. This is called the Collatz Problem or Conjecture s. Clarification: the length of the above Collatz sequence is 10 (the number of terms in the sequencel Directions: Given an initial term implement a Collatz sequence, and find its length. Input: a Output: the length of the Collatz sequence and the terms of the sequence
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
