Question: This program needs to be in Java. 4. The 3N+1 Problem Given a positive integer N, define number, then divide N by 2; but if


This program needs to be in Java.
4. The 3N+1 Problem Given a positive integer N, define number, then divide N by 2; but if N is odd, then multiply N by 3 and add 1. Continue to generate numbers in this way until N become equal to 1. For example, starting from N 3, which is odd, we multiply N by 3 and add 1, giving N 10. Then, since N is even, we divide by 2, giving N-5. We continue in this way, stopping when we reach 1. The complete sequence is: 3, 10, 5, 16, 8, 4, 2,1 Write a program that will read a positive integer from the user and will print out the 3N+1 sequence starting from that integer
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
