Question: Write a code to simulate Collatz conjecture. The code should ask for a positive integer number from the user ( perform sanity check ) and
Write a code to simulate Collatz conjecture. The code should ask for a positive integer number from the user perform sanity check and then implement the following procedure repeatedly:
If the number is even, divide it by two.
If the number is odd, triple it and add one.
The process will stop when it reaches The code should print the number in each step. It should also report how many steps it takes to reach
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
