-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20.cpp
More file actions
29 lines (21 loc) · 672 Bytes
/
Copy path20.cpp
File metadata and controls
29 lines (21 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
*/
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
const string big = "93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000";
int main() {
int sum = 0;
for (int i = 0; i < big.size(); i++) {
if (big[i] != ' ') {
sum += (big[i] - '0');
}
}
cout << sum << endl;
return 0;
}