RosettaCodeData/Task/Multifactorial/00DESCRIPTION

18 lines
1.1 KiB
Text
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
The factorial of a number, written as <math>n!</math>, is defined as <math>n! = n(n-1)(n-2)...(2)(1)</math>.
2013-04-10 21:29:02 -07:00
2015-11-18 06:14:39 +00:00
[http://mathworld.wolfram.com/Multifactorial.html Multifactorials] generalize factorials as follows:
2013-04-10 21:29:02 -07:00
: <math>n! = n(n-1)(n-2)...(2)(1)</math>
: <math>n!! = n(n-2)(n-4)...</math>
: <math>n!! ! = n(n-3)(n-6)...</math>
: <math>n!! !! = n(n-4)(n-8)...</math>
: <math>n!! !! ! = n(n-5)(n-10)...</math>
2015-11-18 06:14:39 +00:00
In all cases, the terms in the products are positive integers.
If we define the degree of the multifactorial as the difference in successive terms that are multiplied together for a multifactorial (the number of exclamation marks), then the task is twofold:
2013-04-10 21:29:02 -07:00
# Write a function that given n and the degree, calculates the multifactorial.
2015-11-18 06:14:39 +00:00
# Use the function to generate and display here a table of the first ten members (1 to 10) of the first five degrees of multifactorial.
2013-04-10 21:29:02 -07:00
2016-12-05 22:15:40 +01:00
'''Note:''' The [[wp:Factorial#Multifactorials|wikipedia entry on multifactorials]] gives a different formula. This task uses the [http://mathworld.wolfram.com/Multifactorial.html Wolfram mathworld definition].