|
Project Euler Homework
|
What is the sum of the digits of the number 2^1000? More...
#include <iostream>Go to the source code of this file.
Classes | |
| class | bigN |
Functions | |
| int | main () |
Variables | |
| const unsigned long long | digits = 1e16 |
| const int | gps = 19 |
What is the sum of the digits of the number 2^1000?
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000?
Definition in file 016.cpp.
| int main | ( | ) |
C++ types:
unsigned long: up to 
unsigned long long: up to 
so multiply 256 by 125 times Since
which has 302 digits, it is split to a number of segments.
Let x be the number in one segment,
each segments should contains at most 16 digits.
So there are a total of
segments.
First multiply each segments by 256, then raise the "carry" digits to next segments.
1.7.3