title: Project Euler number 48
body: <p>Here's the problem statement.</p>
  
  <p>The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.</p>
  
  <p>Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000?</p>
  
  <p>The question's pretty straightforward.
  The code which I've written can correctly find all the individual numbers(ie (1^1,2^2,...997^997 etc and they're all correct because I checked using WolframAlpha) :)
  The glitch occurs when i try to add all these numbers. My program always outputs 0.
  I've read through it many times and somehow can't manage to find the error.</p>
  
  <p>PS-Since the numbers here are too large, I've stored the individual digits in an array.
  Code</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int n[1001][3001]={};
  int sum[3001]={};
  int raisedto(int q)
  {
      int i,j;    
      //int digit;
      int carry=0;
      int carry1=0;
      n[q][0]=q;
      for(i=0;i&lt;q-1;i++)
      {
  
      for(j=0;j&lt;3001;j++)
      {
          carry=(q*n[q][j]+carry1)/10;
          n[q][j]=((q*n[q][j])+carry1)%10;
          carry1=carry;
      }
      carry1=0;
      carry=0;
      }
  return(0);      
  }
  int sumof()
  {
      int i,j,carry=0,carry1=0;
      for(i=0;i&lt;1001;i=i+2)
      {
          for(j=0;j&lt;3001;j++)
          {
              carry=(n[i][j]+n[i+1][j]+carry1)/10;
              sum[j]=(n[i][j]+n[i+1][j]+carry1)%10;
              carry1=carry;
          }   
          carry1=0;
          carry=0;
  
      }   
      return(0);
  }       
  int main(void)
  {
      int j,i;
      for(i=0;i&lt;1001;i++)
      {
      printf("%d",i);
      raisedto(i);
      }
      printf("\n");
      sumof();
  
      for(j=0;j&lt;3001;j++)
      {
          printf("%d",sum[j]);
      }   
      printf("done");
      return(0);
  }
  </code></pre>