it's a beginner's problem. I am trying to calculate sum of the first 15 factorials. I know int isn't large enough for the sum, so I used unsigned long long but it still didn't work. why?? Thanks for helping!
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstring>
using namespace std;
int main()
{
const int fac = 15;
unsigned long long sum = 0;
int start = 1;
for (int i = 1; i <= fac; i++){
start = start * i;
sum += start;
cout << fixed << setprecision(0) << i << " " << sum <<endl;
}
}