HELP!! HELP!! HELP!! PLEASE! PLEASE! what is a recursive relation ?
something like \[a_n=a_{n-1}+a_{n-2}\]
so the books say.. but then.. how does it work ?
something that keeps on giving :)
A{n} is the name of the nth value A{n+r} = the name of the nth +r value
It means that each term is defined by reference to previous one, a famous example being the Fibonacci series.
0,1,1,2,3,5,8,13,21...
Okay. Some functions are explicit. That means, if you want to know f(n), you just plug in n and solve the equation. f(n) = 5n+2 is an explicit function. Recursive functions refer to themselves INSIDE of the function. So you can't always just plug in the variables and solve. You may have to do the function for the previous number many many times to solve for f(n). Here's an example. The Fibonacci sequence is defined like this: f(1) = 1, that is, if n = 1, f(n) = 1 f(2) = 1, that is, if n=2, f(n) = 2 f(n) = f(n-2) + f(n-2), that is, if n is greater than 2, then f(n) is the sum of the previous two terms. The sequence ends up going 1, 1, 2, 3, 5, 8, 13... Notice how each term is the sum of the previous two terms. Now what happens if I ask you to compute f(30)? Well, f(30) = f(28) +f(29), so you have to compute f(29) and f(28), which means you have to compute f(27) and everything before it back to f(1). That's an example of recursion.
Oh no! I made a big mistake. One that might confuse you a lot.
In that 3rd part where I was defining the Fibonacci sequence, f(n) is supposed to be f(n) = f(n-2) + f(n-1)
Smooth, thank you! Got the idea.. it calls up itself.. so it isn't "solvable" but its a function anyway!
Yes exactly. A hint that a function is recursive is if you see something like f(something) = f(somethingelse)
Join our real-time social learning platform and learn together with your friends!