Prashant Prashant - 9 months ago 52
C Question

How to calculate 2 to the power 10000000

How to calclute 2 to the power 10000000 without crashing the compiler. What shoud be data type for extramily big integer in c/c++.


Store the digits in an int array where each location of the array denotes one digit. Then multiply them repetitively. That way you will get the answer with out crashing the compiler.

Well you need 302 locations for that. And the multiplication is simply the one that we do in grade classes. You have implement it in coding.

Little bit of code

int d[400];

for(int i=0;i<399;i++)


int carry=0;
int temp=0;
for(int j=0;j<=999;j++)
   for(int i=0;i<=399;i++)
      d[i]= temp%10;
      carry = temp/10;
print d[0..399] in reverse order trimming zeroes.