// total mass of N balls #include #include using namespace std; const int N = 100; // no. of balls int main() { double M=0; // partial sum, which becomes total mass int i=0; // ball counter while (i < N){ // repeat N times double m = i; // m_i (mass of i-th ball) M += m ; // i.e. M=M+m ( add m_i to partial sum ) ++i; // i.e. i=i+1 ( increase ball counter ) } cout << M << endl; }