SyntaxFix
Write A Post
Hire A Developer
Questions
If all you want to do is calculate the sum of 1,2,3... n then you could use :
int sum = (n * (n + 1)) / 2;