illustrative examples the factorial function to demonstrate the mechanics of recursionwe begin with simple mathematical example of computing the value of the factorial function the factorial of positive integer ndenoted !is defined as the product of the integers from to if then nis defined as by convention more formallyfor any integer > ( ( if if > for example the factorial function is important because it is known to equal the number of ways in which distinct items can be arranged into sequencethat isthe number of permutations of items for examplethe three characters aband can be arranged in waysabcacbbacbcacaband cba there is natural recursive definition for the factorial function to see thisobserve that ( more generallyfor positive integer nwe can define nto be ( )this recursive definition can be formalized as ( )if if > this definition is typical of many recursive definitions firstit contains one or more base caseswhich are defined nonrecursively in terms of fixed quantities in this casen is the base case it also contains one or more recursive caseswhich are defined by appealing to the definition of the function being defined recursive implementation of the factorial function recursion is not just mathematical notationwe can use recursion to design python implementation of factorial functionas shown in code fragment def factorial( ) if = return else return factorial( - code fragment recursive implementation of the factorial function