Problems
Recursion - 2
Recursion - 2
The integers $a$, $b$, $c$ are given. Implement the recursive function:
$f(n) = \begin{cases} a, n = 0\\f(n - 1) + bn + c, n > 0\end{cases}$
Input
Four integers $a, b, c\:(|a|, |b|, |c| \le 1000), n\:(0 \le n \le 1000)$.
Output
Print the value of $f(n)$.
Input example #1
4 2 -3 10
Output example #1
84