The first one is obviously equal to:
F(n) = F(0) + n*(n+1)/2
and can be computed in O(1) time. For the second, look here.
Supposing that you want to compute the first one with matrix exponentiation, in the same way that you did with the Fibonacci series, here's the matrix you should use:
| 1 1 0 |
A = | 0 1 1 |
| 0 0 1 |
The choice of matrix is obvious if you think of the following equation:
| F(n+1) | | 1 1 0 | | F(n) |
| n+1 | = | 0 1 1 | * | n |
| 1 | | 0 0 1 | | 1 |
Of course, the starting vector has to be: (F(0), 0, 1)
.
For the second series this is not so easy, as you would want to gradually compute the value 1/n
, which cannot be computed linearly in this way. I guess it cannot be done but I won't try to prove it.