Below is an algorithm for finding the factorial of an integer number using recursion:
function fact(n):
if (n==1):
return 1
return n*fact(n - 1)
Can you rewrite the algorithm using memoization to improve performance? Let's assume we are calling the function only once.