First, the answer to what is factorial. Factorial is denoted by '!' N! = N * (N-1) * (N-2) * ... * 3 * 2 * 1. For example, 5! = 5 * 4 * 3 * 2 * 1 = 120.
There are two approaches to coding a function that will calculate n!. One does it iteratively, and the other recursively.
Iteratively:
factorial (n){
result <- 1
for(i <- 1; i <= n; i <- i + 1){
result <- result * i
}
return result
}
Recursively:
factorial (n){
if n is 1 return 1
return n * factorial(n - 1)
}
Note that n must be 1 or greater for each of the above methods.
hi darling
5! = 5*4*3*2*1 = 120
To write pseudocode in Microsoft Word, you can use the built-in Equation Editor or insert a text box and type your pseudocode inside it. You can also use a monospaced font like Courier New to format your pseudocode for better readability.
pseudocode
pseudocode
SPOK (Structured Prose Organizer for KEDIT) is a pseudocode design tool. (SPOK4 at Verizon.Net)
structured English resembles spoken Englishwhere as pseudocode resembles programming languageWhat_are_the_differences_between_structured_English_and_pseudo_code
Develop an algorithm to display all prime numbers from 2 to 100. Give both the pseudocode version and the flowchart version. Convert your pseudocode into a Java program.
pseudocode is a sentence-like representation of a piece of code while a trace table is a technique used to test a algorithms.
pseudocode
enables the programmer to concentrate on algorithms.
pseudocode