diff --git a/src/Numerics/Combinatorics.cs b/src/Numerics/Combinatorics.cs
index b3ae25b9..eb12fe6f 100644
--- a/src/Numerics/Combinatorics.cs
+++ b/src/Numerics/Combinatorics.cs
@@ -36,7 +36,7 @@ namespace MathNet.Numerics
public static class Combinatorics
{
///
- /// Computes the number of variations without repetition.
+ /// Counts the number of possible variations without repetition.
/// The order matters and each object can be chosen only once.
///
/// Number of elements in the set.
@@ -56,7 +56,7 @@ namespace MathNet.Numerics
}
///
- /// Computes the number of variations with repetition.
+ /// Counts the number of possible variations with repetition.
/// The order matters and each object can be chosen more than once.
///
/// Number of elements in the set.
@@ -73,7 +73,7 @@ namespace MathNet.Numerics
}
///
- /// Computes the number of combinations without repetition.
+ /// Counts the number of possible combinations without repetition.
/// The order does not matter and each object can be chosen only once.
///
/// Number of elements in the set.
@@ -85,7 +85,7 @@ namespace MathNet.Numerics
}
///
- /// Computes the number of combinations with repetition.
+ /// Counts the number of possible combinations with repetition.
/// The order does not matter and an object can be chosen more than once.
///
/// Number of elements in the set.
@@ -109,5 +109,15 @@ namespace MathNet.Numerics
- SpecialFunctions.FactorialLn(k)
- SpecialFunctions.FactorialLn(n - 1)));
}
+
+ ///
+ /// Counts the number of possible permutations (without repetition).
+ ///
+ /// Number of (distinguishable) elements in the set.
+ /// Maximum number of permutations without repetition.
+ public static double Permutations(int n)
+ {
+ return SpecialFunctions.Factorial(n);
+ }
}
}
\ No newline at end of file
diff --git a/src/UnitTests/CombinatoricsTests/CombinatoricsCountingTest.cs b/src/UnitTests/CombinatoricsTests/CombinatoricsCountingTest.cs
index 7b196bf0..68cfdcdb 100644
--- a/src/UnitTests/CombinatoricsTests/CombinatoricsCountingTest.cs
+++ b/src/UnitTests/CombinatoricsTests/CombinatoricsCountingTest.cs
@@ -160,5 +160,19 @@ namespace MathNet.Numerics.UnitTests.CombinatoricsTests
Combinatorics.CombinationsWithRepetition(n, k),
"The number of combinations with repetition but out of the range must be 0.");
}
+
+ [Test]
+ [Row(0, 1)]
+ [Row(1, 1)]
+ [Row(2, 2)]
+ [Row(8, 40320)]
+ [Row(15, 1307674368000)]
+ public void CanCountPermutations(int n, long expected)
+ {
+ Assert.AreEqual(
+ expected,
+ Combinatorics.Permutations(n),
+ "Count the number of permutations");
+ }
}
}
\ No newline at end of file