Factorial: Difference between revisions
→{{header|bash}}
BackslashPhi (talk | contribs) |
|||
Line 1,299:
}
</syntaxhighlight>
===Imperative===
<syntaxhighlight lang="bash">factorial()
{
declare -nI _result=$1
declare -i n=$2
_result=1
while (( n > 0 )); do
let _result*=n
let n-=1
done
}
</syntaxhighlight>
(the imperative version will write to a variable, and can be used as <code>factorial f 10; echo $f</code>)
=={{header|BASIC}}==
|