Definition: | atom a = factorial(integer n) |
Description: | Standard recursive factorial function, with memoisation. |
Comments: | Returns inf for n>170. |
Ancilliary functions: |
atom res = k_perm(integer n, k) -- standard partial permutations calculation (sequences without repetition)
atom res = choose(integer n, k) -- standard combinations calculation - choose k from n aka "n choose k" The k_perm routine calculates the result directly, rather than via the slightly less efficient (/limit-exceeding) way of using the complete factorials, ie n(n-1)..(n-k-1) rather than n!/(n-k)! and the choose routine simply divides that by factorial(k). |
Example: |
-- n : 0 1 2 3 4 5 6 7 8 -- factorial(n): 1 1 2 6 24 120 720 5040 40320 |