a ::: a%2
1 ::: 1
2 ::: 0
3 ::: 1
4 ::: 0
5 ::: 1
if (a%2==0) ...
I need an algorithm that calculates 1-1/2+1/3...(or-)1/n for any given n. 1/k is added to the sum if k is odd and subtracted from the sum if k is even.
If someone can assist me and explain to me how you did it, I would love you.