Filter löschen
Filter löschen

how to implement this psuedocode as script

2 Ansichten (letzte 30 Tage)
Raiven Balderas
Raiven Balderas am 7 Mär. 2018
Bearbeitet: Raiven Balderas am 7 Mär. 2018
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Mär. 2018

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by