Basic questions. Seeking 1 + 3 + 6 + ... + i (i +1) and / 2, the summation formula of N * (N + 1) * (N + 2) / 6, its logarithmic 10, determining the number after E.
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int N;
while (cin >> N)
{
if (N == 0)
break;
double sum = 1.0 * N * (N + 1) * (N + 2) / 6;
int num = log10(sum);
sum /= pow(10, num);
cout << fixed << setprecision(2) << sum << "E" << num << endl;
}
return 0;
}
Keep up.