permutation implementation and tests in recursive and iterative styles