Ask your own question, for FREE!
Mathematics 70 Online
OpenStudy (anonymous):

Matlab help?! Write a matlab code to prove (or disprove) the Collatz Conjecture. Run the code for a few different values of n, and make note of the results. Did n always eventually go to 1? Tips: You will need to use a while loop. While your integer, n, is greater than 1, you want to continue doing the calculation (i.e. n/2 if even and 3n+1 if odd). Once n reaches 1 (or something less?), you want the program to end. Within the while loop, an if statement is necessary to determine which calculation you should do, depending on if n is even or odd at the time( by using the mod function).

OpenStudy (phi):

while (n> 1) if (mod(n,2)) % this is odd if 1 (true) disp('ODD'); else disp('EVEN'); end; end; % while n>1 disp('n less than or equal to 1');

OpenStudy (phi):

is this what you want ? n=5 while (n> 1) if (mod(n,2)) % this is odd %disp('ODD'); n= 3*n+1 else %disp('EVEN'); n= n/2 end end; % while n>1

OpenStudy (anonymous):

Let me check it in matlab, hold on (:

OpenStudy (anonymous):

perfect (: <3

OpenStudy (phi):

Please e-mail me your 'A'

OpenStudy (anonymous):

my 'A'?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
luvnickk: If yalll fw the weeknd your a 10 !!
4 minutes ago 9 Replies 1 Medal
Ash2746: Anyone know anything interesting about the Cold War?
37 minutes ago 8 Replies 1 Medal
Austinsbabygirl4life: Texas schools look funn
14 minutes ago 5 Replies 2 Medals
chuu: Is it (Hunt 30-31) or (Hunt 30-1) in MLA?
1 hour ago 1 Reply 0 Medals
luvnickk: what typa music yall listen to ?
15 minutes ago 28 Replies 3 Medals
GothgirlLillian: Is music considered art?
21 minutes ago 8 Replies 0 Medals
luvnickk: am newwww
13 hours ago 0 Replies 0 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!