필터 지우기
필터 지우기

The Collatz Problem, help writing a program for this?

조회 수: 2 (최근 30일)
Reelz
Reelz 2012년 4월 16일
Here is the collatz problem:
X_k+1 x_k/2 if x_k is even
{ for k = 0,1,2...
3_xk+1 if x_k is odd
I am looking for some positive integer x_0 as a starting value where the sequence should terminate when x_n = 1. I Want my program to run with x_0 = m for each integer m from 1 through 3000. I want to make a graph of these values on my x - axis, and the number of steps the sequence takes to terminate when starting from x_0 = m on the y-axis. Then with x_0 for the largest number of steps, make a graph with the values of k on the x-axis and values of x_k on the y-axis.
It is mainly the code I need help with, writing the program. I found this exercise from a student who said it would help me but I just can't figure out how to go about doing it. I would greatly appreciate some good help.

답변 (1개)

Sean de Wolski
Sean de Wolski 2012년 4월 16일
docsearch collatz
Might be a good place to start

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by