Which of the following pieces of Scilab code calculates n! correctly?2. j = n f=n while (j>= 2) j= j-1 f= f*j end disp(f)3. j = n f=n while (j>= 1) j= j-1 f= f*j end disp(f)4. j = n f=n while (j>= 0) j= j-1 f= f*j end disp(f)

🎲 Try a Random Question  |  Total Questions in Quiz: 64  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
ME101: Final Exam - Introduction to Mechanical Engineering — practice the complete quiz, review flashcards, or try a random question.

MCQs on the basics of Mechanical Engineering.


Which of the following pieces of Scilab code calculates n! correctly?<br>2. j = n<br> f=n<br> while (j>= 2)<br> j= j-1<br> f= f*j<br> end<br> disp(f)<br/><br>3. j = n<br> f=n<br> while (j>= 1)<br> j= j-1<br> f= f*j<br> end<br> disp(f)<br/><br/><br>4. j = n<br> f=n<br> while (j>= 0)<br> j= j-1<br> f= f*j<br> end<br> disp(f)<br/>