Turning Haskell self-recursion into a mathematical formula

38 Views Asked by At

I have a Haskell function, which uses self-recursion to a limit

stock 0 = 0
stock n = (n*3) + (stock (n-1))

however, I somehow have to turn this function into something my calculator can understand. I'm personally not that good with mathematical notation, and prefer sticking to programming, but I am forced to do it here.

1

There are 1 best solutions below

0
On BEST ANSWER

Let $x_n$ denote "stock n." Then induction shows

$$x_n=\frac{3}{2}n(n+1).\quad (1)$$

The base case is trivial. And (1) implies

$$x_{n+1}=3(n+1)+x_{n}=3(n+1)+\frac{3}{2}n(n+1)=\frac{3}{2}(n+1)(n+2).$$