Azzera filtri
Azzera filtri

how to implement this psuedocode as script

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 7 Mar 2018

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by