I tried to identify the simplified reccurence formula for the following function:g(0) = x ; g(n) = g(n - 1) + 1/2 (1 - sqrt(8 g(n - 1) + 1))
But the answer given by wolfram alpha is g(n) = 1/2 n (n + sqrt(8 x + 1)) + x which is clearly wrong because for g(0)=10 we have g(10)=0 Thank you in advance,
I presume the problem with the program must be with the taking of the square root. This is perhaps illustrated by a neat 'by hand' solution is as follows.
Let $8g_n+1=y_n^2$. Then $y_{n+1}=|y_n-2|.$
Your series $10,6,3,1,0,0,0...$ then corresponds to $9,7,5,3,1,1,1,...$.
However, we could have taken $y_{n+1}=-|y_n-2|$ and obtained a different series.