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
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.