필터 지우기
필터 지우기

how to implement this psuedocode as script

조회 수: 2 (최근 30일)
Raiven Balderas
Raiven Balderas 2018년 3월 7일
편집: Raiven Balderas 2018년 3월 7일
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

채택된 답변

Walter Roberson
Walter Roberson 2018년 3월 7일

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by