Difference between revisions of "Recursion"

(added first example problem)
(categories)
Line 1: Line 1:
'''Recursion''' is a method of defining something (usually a [[sequence]] or [[function]]) in terms of previously defined values.  The most famous example of a recursive definition is that of the [[Fibonacci sequence]].  If we let <math>F_n</math> be the <math>n</math>th Fibonacci number, the sequence is defined recursively by the relations <math>F_0 = F_1 = 1</math> and <math>F_{n+1}=F_{n}+F_{n-1}</math>.  (That is, each term is the sum of the previous two terms.)  Then we can easily calculate early values of the sequence in terms of previous values: <math>\displaystyle F_0=1, F_1=1, F_2=2, F_3=3, F_4=5, F_5=8</math>, and so on.
+
'''Recursion''' is a method of defining something (usually a [[sequence]] or [[function]]) in terms of previously defined values.  The most famous example of a recursive definition is that of the [[Fibonacci sequence]].  If we let <math>F_n</math> be the <math>n</math>th Fibonacci number, the sequence is defined recursively by the relations <math>F_0 = F_1 = 1</math> and <math>F_{n+1}=F_{n}+F_{n-1}</math>.  (That is, each term is the sum of the previous two terms.)  Then we can easily calculate early values of the sequence in terms of previous values: <math>F_0=1, F_1=1, F_2=2, F_3=3, F_4=5, F_5=8</math>, and so on.
  
Often, it is convenient to convert a recursive definition into a closed-form definition.  For instance, the sequence defined recursively by <math>\displaystyle a_0 = 1</math> and <math>a_n = n\cdot a_{n - 1}</math> for <math>n > 0</math> also has the closed-form definition <math>\displaystyle a_n = n!</math> (where "!" represents the [[factorial]] function).
+
Often, it is convenient to convert a recursive definition into a closed-form definition.  For instance, the sequence defined recursively by <math>a_0 = 1</math> and <math>a_n = n\cdot a_{n - 1}</math> for <math>n > 0</math> also has the closed-form definition <math>a_n = n!</math> (where "!" represents the [[factorial]] function).
  
  
Line 16: Line 16:
 
* [[Sequence]]
 
* [[Sequence]]
 
* [[Induction]]
 
* [[Induction]]
 +
 +
[[Category:Definition]]

Revision as of 20:07, 7 December 2007

Recursion is a method of defining something (usually a sequence or function) in terms of previously defined values. The most famous example of a recursive definition is that of the Fibonacci sequence. If we let $F_n$ be the $n$th Fibonacci number, the sequence is defined recursively by the relations $F_0 = F_1 = 1$ and $F_{n+1}=F_{n}+F_{n-1}$. (That is, each term is the sum of the previous two terms.) Then we can easily calculate early values of the sequence in terms of previous values: $F_0=1, F_1=1, F_2=2, F_3=3, F_4=5, F_5=8$, and so on.

Often, it is convenient to convert a recursive definition into a closed-form definition. For instance, the sequence defined recursively by $a_0 = 1$ and $a_n = n\cdot a_{n - 1}$ for $n > 0$ also has the closed-form definition $a_n = n!$ (where "!" represents the factorial function).


Examples


See also