Question: 3. The Collatz conjecture problem in mathematics asks whether repeating two simple arithmetic operations will eventually transform every positive integer into one. Consider the following

3. The Collatz conjecture problem in mathematics asks whether repeating two simple arithmetic operations will eventually transform every positive integer into one. Consider the following rule that transforms a given positive integer x to another (hailstone): if x is even, it becomes x/2; if x is odd, it becomes 3x+1. Starting at an arbitrary integer, we can repeatedly apply the rule. For example: 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. It has been conjectured that all integers eventually yield a 1. You can referred to this as the "Collatz conjecture", a.k.a. the "3x+1" problem. The conjecture has been verified by computer up to 5.6*10^13. In this assignment, you are to write a MIPS program to verify this conjecture to some extent. Your program will read a positive integer x from the user and repeatedly apply the rule above, print each hailstone (transformed values) until it reaches 1. The basic pseudo code is given here: while (x > 1){ if (x is even){ n=n/2} else{ n= 3*n+ 1} This solution is further constrained by requiring the use of two functions to implement the two kinds of transformation: One function will take an input x and return 3*x+1, while the other function divides its argument by 2. Try not using divide or multiply instructions. Rather use a shift right arithmetic (sra) instruction for division by 2, and use a combination of shift left logical (sll) and addition instructions to multiply by 3. Submit your solution as MIPS assembly file (collatz.asm)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
