Permutations by looping
Richard A. DeVenezia, April 2004
Determine the permutations of N things by dynamically creating a javascript function that has N nested loops. The generated function uses bit logic to determine membership in a set, thus N must be <= 32. Realistically, N=9 is the edge of feasibility in client side javascript.
Fi = number of ifs
Fn = n2 ( 1 + (n-1) * ( 1 + (n-2) * ( 1 + ... * ( 1 + 3 * ( 1 + 2 )) ... ))))
F1 = 0
Fn = n2 * ( 1 + Fn-1 / (n-1) )