Professional Documents
Culture Documents
Info Tech
Info Tech
In Pseudocode form:
function findLargestNumber(array)
largest = array[0]
for i = 1 to length(array) - 1 do
if array[i] > largest then
largest = array[i]
end if
end for
return largest
end function
B. Design an algorithm to find the factorial of a number.
1. Initialize a variable `factorial` to 1.
2. Iterate from 1 to the given number (inclusive):
- Multiply `factorial` by the current number and update `factorial`.
3. After the loop, `factorial` will hold the factorial of the given number.
4. Return `factorial` as the result.