I need to write a few functions in Python.
Write two versions of a factorial function.
#This is the iterative version that uses a loop with an accumulator. Given n, return n!.
#This is a recursive solution where:
#rfac(n) = 1, if n=0
# =n * rfac(n-1), otherwise.
#Permutations - Implement the function perm(n,r) that returns
the number of ways to arrange r items out of a set of n
#Combinations - returns the number of ways to choose r items out
of a set of n items where order does not matter.
#Fibonacci Numbers that returns the nth Fibonacci number. The
fibonacci sequence starts with 0,1. Each successive number is
calculated by summing the previous two numbers. This is a recursive
#Memoization - uses memoization to greatly speed up the
calculation. Use a dictionary to memoize each value of fib(n) as
they are computed.
#Pascal's Triangle - construct pascal's triangle, each number at
a given (row, column) locationcan be computed by summing the two
numbers above it. The numbers on the edges are always 1. The
function below computes the number at the given (rwo, col) by using
the formula above. This is a recursive function. The base case is
when (row, col) corresponds to one of the edges. Otherwise, it sums
the two values above.
def pascal(row, col):
#Memoization - make a new function called mpascal(row,col) that uses memoization to speed up the computation.
def mpascal(row, col):
Thanks in advance!!!!