For my studies, I have to code an algorithm to calculate sin() with this function:

There are two problems with your code:
sin(x+k*π/2) does not necessarily equal sin(x)i=0 and then use the equation in your question to compute the next term in each iteration.