I am writing a program to add integers 1+2+3...etc. The sum can not exceed
2500. But after i output the sum, it shows 2556. Can anyone help me fixing it. Thank you so much.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
int number=1,sum=0;
while(sum<2500)
{
sum=sum+number;
number++;
}
cout<<sum;
return 0;
}