# 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.

**F _{i} = number of ifs**

F_{n} = n^{2} ( 1 + (n-1) * ( 1 + (n-2) * ( 1 + ... * ( 1 + 3 * ( 1 + 2 )) ... ))))

F_{1} = 0

F_{n} = n^{2} * ( 1 + F_{n-1} / (n-1) )