Confusing Problem

Nov 8, 2014 at 7:26pm
So, I have no code for this yet.. I cannot even understand the question enough to know where to begin. I was hoping someone would be generous enough to explain it to me and provide some much needed insight.

Thanks


Suppose that the first number of a sequence is x, in which x is an integer.
Define a0 ¼ x; an+1 ¼ an/2 if an is even; an+1 ¼ 3  an + 1 if an is odd.
Then, there exists an integer k such that ak ¼ 1. Write a program that prompts
the user to input the value of x. The program output the integer k such
that ak ¼ 1 and the numbers a0, a1, a2, ... , ak. (For example, if x ¼ 75, then
k ¼ 14, and the numbers a0, a1, a2, . . ., a14, respectively, are 75, 226, 113, 340,
170, 85, 256, 128, 64, 32, 16, 8, 4, 2, 1.) Test your program for the following
values of x: 75, 111, 678, 732, 873, 2048, and 65535.
Nov 8, 2014 at 9:29pm
https://en.wikipedia.org/wiki/Collatz_conjecture
It is asking you to write the sequence and the number of steps to reach it.
Nov 8, 2014 at 9:35pm
My teacher said that I cannot use user-defined functions. Last time I turned in code with Collatz in it, that is what he said. Would Collatz be considered user-defined?
Nov 8, 2014 at 10:56pm
First question. Do you know what the collatz conjecture is? And the basics of what he is expecting the program to do? And lastly what was the "collatz" code that he previously rejected?

Making the function is simple enough. However any restrictions he placed on how you can implement it can make it much tougher. If he wanted this specific assignment to not contain user defined functions he would have explicitly said so

Topic archived. No new replies allowed.