Recursive definition attempt.

111 Views Asked by At

I have the following question:


$\text{b) }$Give a recursive definition for the function $f:\Bbb N\to\Bbb N$ which calculates the following sum for any $x\in\mathbb N$: $$f(x)=20+(20+1)+\ldots+(20+x)$$ For example, $f(2)=20+(20+1)+(20+2)$.


$f(x) = f(x-1)+20+x$

It looks wrong, however it could possibly be right : $=/$.

2

There are 2 best solutions below

0
On

You are correct with your recursive definition, if we have:

$$f(x)=f(x-1)+20+x$$

However, we need to set the initial condition: $f(0)=20$. Once we have done this we can clearly see that for any $x\in\mathbb{N}$ we have:

$$f(x)=20+(20+1)+\cdots+(20+x)=\sum_{n=0}^{x}(20+n)$$

As a side note you might note that this can easily be solved using standard closed-form summations to give a more efficient to calculate form of $f(x)$:

$$f(x)=\frac{(x+1)(x+40)}{2}$$

0
On

Your functional equation is correct $$f(x)=20(x+1)+\frac{x(x+1)}{2}$$ $$f(x)=f(x-1)+20+x$$