How can I set up the variables for this question?
Ältere Kommentare anzeigen
Take any natural number n. If n is even, divide it by 2 to get n/2. If n is odd, multiply it by 3 and add 1 to obtain 3n+1. (This is called the Hailstone sequence).
Set the new number to n and repeat this process until n=1.
How many steps does it take for 71 to get to 1?
I'm a total idiot in Matlab in the real sense of the word. I have problem translating theories into practice. I need a leg up on understanding how I can apply concepts to solve this problem.
2 Kommentare
Walter Roberson
am 5 Sep. 2013
Lots of examples in the documentation.
cwc
am 5 Sep. 2013
Akzeptierte Antwort
Weitere Antworten (1)
cwc
am 6 Sep. 2013
Bearbeitet: Image Analyst
am 6 Sep. 2013
2 Kommentare
Image Analyst
am 6 Sep. 2013
Looks like it should work.
Walter Roberson
am 6 Sep. 2013
Good thing that infinity is not a "natural number" ;-)
Still, I think the code will start misbehaving at about 2^51
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!