This is due tomorrow, and i am absoltuly lost, can anyone help with some examples or point in the right direction, MANY THANKS for any help
Mathematician Stanislav Ulam proposed that any positive integer would reduce to 1 if the following algorithm was repeated a sufficient number of times.
If the number is even, divide it by 2.
If the number is odd, multiply it by 3 and then add 1.
For example, if the original number were 13, the algorithm would generate the following sequence of numbers: 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. This sequence has 10 terms counting the original number and the 1.
Write a program that accomplishes the following three functions:
Prompts the user for a positive integer input, or a zero to exit. This prompt should be repeated if the user enters a negative number.
Outputs all the numbers in the sequence produced by the Ulam algorithm.
Counts how many numbers are in the sequence, and outputs the count.