MATLAB Answers

how to implement this psuedocode as script

1 view (last 30 days)
Implement the following pseudocode within your script.
n = a randomly chosen integer between 1 and 10^6
Display n to the screen
maxiter = 10^4
for k = 1, 2, . . . , maxiter
If n = 1, then
display iteration k to the screen
stop your loop
end if statement
If n is even
n = n/2
otherwise (that is, if n is odd)
n = 3n + 1
end if statement
end for loop

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags