Question: Please help me write this JavaScript code (and please include all requirements). Introduction: In this lab, you will get practice with conditional repetition (loops) The
Introduction: In this lab, you will get practice with conditional repetition (loops) The Collatz conjecture is a conjecture in Mathematics that remains unsolved at the time of writing this lab. It involves a sequence that goes like this: start with any positive integer called N. The next term in the sequence is computed using the current term as follows. If the current term is even, then the next term in the sequence is the current term, divided by two. Otherwise, if the current term is odd, then the next term in the sequence is three times the current term, plus one. Apply the rule to get the next term until the current term is 1, at which point, stop. For example, suppose that we start with the number 3: 1. Since 3 is odd, the next term is 3(3) +1 10. 2. Since 10 is even, the next term is 10/2-5. 3. Since 5 is odd, the next term is 3(5) +1-16. 4. Since 16 is even, the next term is 16/2 8. 5. Since 8 is even, the next term is 8/2-4 6. Since 4 is even, the next term is 4/2-2 7. Since 2 is even, the next term is 2/2-1. Mathematicians conjecture (they believe that it is true) that, no matter what the starting value (as long as its positive), the above sequence, if carried out correctly, will ALWAYS end with 1 after some number of steps. This conjecture is sometimes referred to as the "Hailstone conjecture" because the next term in the sequence, like a real hailstone, ascends and descends in the atmosphere and eventually falls to the ground. In this lab you will write a web page to compute and display hailstone sequences. Your web page should let the user type in a "maximum" value, and assuming this value is valid, it should display the hailstone sequences for all positive starting values less than or equal to the maximum value given by the user (see the Sample screens section). At the heart of your web page will be two conditional repetition statements (loops): one to compute a hailstone sequence for a given starting value and the other one will repeatedly call the previous ond
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
