Question: In Java Please!!! Project 1: Collatz Sequences (COL] Textbook Section: 4.23 Set Up: In a Collatz sequence, all of its terms are positive integers which
In Java Please!!!
Project 1: Collatz Sequences (COL] Textbook Section: 4.23 Set Up: In a Collatz sequence, all of its terms are positive integers which satisfy the following recursive formula an an-1 if an-1 is even an = 3an-1 + 1 if an-1 is odd For example, if the first term in the sequence is a1 = 13, then the recursive formula gives the corresponding Collatz sequence: 13 40 20 10 5 16 8 4 2 1 Note, it is thought that all Collatz sequences end with 1. This is called the Collatz Problem or Conjecture c. Clarification: the length of the above Collatz sequence is 10 (the number of terms in the sequence). Directions: Given an initial term implement a Collatz sequence, and find its length. Input: ai Output: the length of the Collatz sequence Extra Credit: Find the length of the longest Collatz sequence when 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
