Recursive Functions




What is a function?

A function is a math equation that means for every 'x' value, there is a 'y' value to graph on a cartesian coordinate plane.    (just a regular graph)
 

What is a recursive function?

Well, a recursive function comes from a function that contains more than 1 equation, and is repetitively substituting back into itself until an answer is found.  That is probably very hard to understand.. so let's look at an example.
 
 

Example #1


    ƒ(7) = ?  where

ƒ(x)   {  ƒ(x-1) + 2    if x>5
         {   6                 if x<=5

ƒ(7) = ƒ(7-1) + 2        since 7 > 5 you use ƒ(x-1) + 2
       = ƒ(6) + 2            now you need ƒ(6)

ƒ(6) = ƒ(6-1) + 2         since 6 > 5 you use f(x-1) + 2 again
       = ƒ(5) + 2            now you need ƒ(5)

ƒ(5) = 6         since 5 = 5, you use 6.

now substite the answer to ƒ(5) into ƒ(6) like this:

ƒ(6) = ƒ(5) + 2
        = 6 + 2
        = 8
now substitute the answer to ƒ(6) into ƒ(7) like this:

ƒ(7) = ƒ(6) + 2
        = 8 + 2
        = 10

ƒ(7) = 10
 
 

Example #2:

Find ƒ(150) where

ƒ(x) = {        ƒ(x-20) + 10            if x > 100
           {        3x                            if x <= 100
 
 
 
 
 

Need help?
 
 

Answer.