This section contains 874 words (approx. 3 pages at 300 words per page) |
A recursive function is a function whose domain is generated by previous values of the function. A recursive function is typically defined by giving some initial value and then stating a recursion rule which defines how a given function value depends on a previous value, or values, of the function. For example, here is a recursive function: f(0) = 2 and f(n) = f(n - 1) + 3 where n is a natural number (positive integer). This function starts with an initial value of 2, after which each new function value is generated by adding 3 to the function value preceding it. So this function will generate the set {2,5,8,11,...}. Another example is: f(0) = 1 and f(n) = nf(n - 1), where n is a natural number. This recursive function generates the set {1,1,2,6,24,120,...} and is called the factorial function. It is usually defined using the factorial symbol (!) as follows: 0! = 1 and n! = n(n -...
This section contains 874 words (approx. 3 pages at 300 words per page) |