Solution Review: Square the Factorials
The solution to the 'Square the Factorials' challenge.
We'll cover the following...
Press + to interact
def factorial(n):if n == 1 or n == 0:return 1else:return n*factorial(n-1)def square_factorial(n):return [(lambda a : a*a)(x) for x in (list(map(factorial, range(n))))]print(square_factorial(6))
Explanation
In the code above, according to the problem statement, there are two parts: the factorial
and the square_factorial
function. Let us first go through the factorial
function.
Look at the function’s header at line 1. It takes a parameter n
. We are using the recursive approach to compute the factorial of the number n
. The recursion will not be explained, as it is not our concern here.
Now, look at ...