Options

Recursive Function Example

The recursive function is $$ f(n)= \begin{cases} 0, & \text{if $x \le 0$}.\\\\ f(n-1) + n, & \text{otherwise}. \end{cases} $$ Assume \( f \) is of the form \( \frac{n(n+1)}{2} \); then $$ f(0) = \frac{0(0+1)}{2} = 0 $$ $$ f(n) = \frac{n(n+1)}{2} = f(n-1) + n = \frac{[n-1]([n-1]+1)}{2} + n $$

Comments

Sign In or Register to comment.