Yes that code uses different signs.
But the whole of the code does not follow the equation and produce the correct answer.
Add a println after each of those assignments to print out the value of var.
Shorten the loop to 10 times and look at the output
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.