Improved Permutations with the BigInteger Data Type

In the September 2012 issue of Visual Studio Magazine I wrote an article titled, “Improved Permutations with the BigInteger Data Type”. See A permutation of n items is a rearrangement of those n items. For example if you have n = 3 items {“red”, “blue”, “green” } then one permutation of the items is { “green”, “red”, “blue” }.

The total number of permutations for a set of n items is n! (read n factorial). The equation for n! is n! = n * (n-1) * (n-2) * . . . 1. For example, 6! = 6 * 5 * 4 * 3 * 2 * 1 = 720. The problem with factorials is that past about 20! or so the value of n! become astronomically large, much larger than an int data type can store.

The .NET Framework 4.0 introduced a BigInteger data type that allows much improved methods that work with permutations. The BigInteger data type can store arbitrarily large integer values and to me, was the single most important feature of .NET 4.0.

This entry was posted in Software Test Automation. Bookmark the permalink.