How to resolve the algorithm Factorial step by step in the Lingo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Factorial step by step in the Lingo programming language
Table of Contents
Problem Statement
Write a function to return the factorial of a number. Solutions can be iterative or recursive. Support for trapping negative n errors is optional.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Factorial step by step in the Lingo programming language
Source code in the lingo programming language
on fact (n)
if n<=1 then return 1
return n * fact(n-1)
end
on fact (n)
res = 1
repeat with i = 2 to n
res = res*i
end repeat
return res
end
You may also check:How to resolve the algorithm Associative array/Creation step by step in the Visual FoxPro programming language
You may also check:How to resolve the algorithm Jaro similarity step by step in the CLU programming language
You may also check:How to resolve the algorithm Hash from two arrays step by step in the Go programming language
You may also check:How to resolve the algorithm String case step by step in the Stata programming language
You may also check:How to resolve the algorithm Odd word problem step by step in the Lua programming language