title: Why can't I find Sum() of this HashSet. says "Arithmetic operation resulted in an overflow."
body: <p>I was trying to solve this problem <a href="http://projecteuler.net/problem=125" rel="nofollow">projecteuler,problem125</a></p>
  
  <p>this is my solution in python(just for understanding the logic) </p>
  
  <pre><code>lim = 10**8
  total=0
  found= set([])
  for start in xrange(1,int(lim**0.5)):
      s=start**2
      for i in xrange(start+1,int(lim**0.5)):
          s += i**2
          if s&gt;lim:
              break
          if str(s) == str(s)[::-1]:
              found.add(s)
  
  print sum(found)
  </code></pre>
  
  <p>the same code I wrote in C# is as follows</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace ConsoleApplication1
  {
      class Program
      {
          public static bool isPalindrome(string s)
          {
              string temp = "";
              for (int i=s.Length-1;i&gt;=0;i-=1){temp+=s[i];}
              return (temp == s);
          }
          static void Main(string[] args)
          {
              int lim = Convert.ToInt32(Math.Pow(10,8));
              var found = new HashSet&lt;int&gt;();
              for (int start = 1; start &lt; Math.Sqrt(lim); start += 1)
              {
                  int s = start *start;
                  for (int i = start + 1; start &lt; Math.Sqrt(lim); i += 1)
                  {
                      s += i * i;
                      if (s &gt; lim) { break; }
                      if (isPalindrome(s.ToString())) 
                      { found.Add(s); }
                  }
              }
              Console.WriteLine(found.Sum());
  
          }
      }
  }
  </code></pre>
  
  <p>the code debugs fine until it gives an exception at  <code>Console.WriteLine(found.Sum());</code> (line31). Why can't I find <code>Sum()</code> of the set <strong>found</strong></p>