Question: 5. Consider the 3n+1 sequence defined as: Given an initial positive value n the next term is n/2 when n is even 3n+1 when n

5. Consider the 3n+1 sequence defined as: Given an initial positive value n the next term is n/2 when n is even 3n+1 when n is odd The sequence ends at 1. For example, given an initial value of 3 the generated sequence is 3, 10, 5, 16, 8, 4, 2, 1 and we see the length of this sequence is 8. Write a program named ThreeNplus1 that displays a frequency count for the lengths of 3n+1 sequences. Use values of n varying from 2 to 100. You must use an array list to hold frequency values. The output from your program must be of the following form: Sequence length frequency 1 2 3 20 or more Submit ThreeNplus1.java. A recommended main method is: public static void main(String[] args) { ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
