Modified Euler 24 to add a base case to permutations (Helpful for Euler 49)