Illustration of a conditional loop, MATLAB Programming

Illustration of a conditional loop - While loop:

As an illustration of a conditional loop, we will write a function which will find the first factorial which is greater than the input argument high. Formerly, we wrote a function to compute a specific factorial. For illustration, to compute 5! We found the product 1 * 2 * 3 * 4 * 5. In that situation a for loop was used, as it was known that the loop would be repeated 5 times. Now, we do not know how many times the loop will be repeated. The fundamental algorithm is to have two variables, one that iterates throughout the values 1, 2, 3, and so forth, and one which stores the factorial of the iterator at each step. We begin with 1, and 1 factorial, that is 1. Then, we confirm the factorial. If it is not bigger than high, the iterator variable will then increment to 2, and finds its factorial (2). If this is not greater than high, the iterators will then increment to 3, and the function will also find its factorial (6). This continues till we get to the first factorial which is greater than high. Therefore, the process of incrementing a variable and finding its factorial is repeated till we get to the first value greater than high. This is implemented by using a while loop:

1371_Illustration of a conditional loop.png

Posted Date: 10/19/2012 6:04:07 AM | Location : United States







Related Discussions:- Illustration of a conditional loop, Assignment Help, Ask Question on Illustration of a conditional loop, Get Answer, Expert's Help, Illustration of a conditional loop Discussions

Write discussion on Illustration of a conditional loop
Your posts are moderated
Related Questions
Illustration  of assignment statements: At that point, if the expression mynum 3 is entered, the default variable ans is used as the result of this expression is not assigned

Compute the result: To compute the area, the formula is required. In this situation, the area of the circle is π multiplied by the radius squared. Therefore, that means the va

whats thye procedure for entering say an LP model, maximisation an objective funtion ''10x+3y'' subject to: 40 300x +298y>=299 x+y=1

Creating matrix variables- arguments: The CAT arguments dimensions are not reliable. The Iterators can also be used for the values on the rows by using the colon operator;

2)''dbcont'' command for debugging is used to Select one: a. Continue normal code execution from the debug prompt. b. List all breakpoints. c. Execute (step) one or more lines

Write a program that reads in numbers (of type double) from a file, stores them in an array, and then calculates the mean, variance, and standard deviation.   Your program shoul

1. Design a suitable phase-lead controller. You should explain in detail how your design has been developed. Your solution should include Bode plots constructed both manually and


Variable names: Variable names are an example of the identifier names. The rules for identifier names are as shown below: (A)The name should begin with a letter of the alph

People arrive at a microscope exhibit at a rate of one every 8+/- 2 minutes. Only one person can see the exhibit at a time. It takes 5 +/- 2 minutes to see the exhibit. A person