title: OverflowError Python int too large to convert to C long
body: <pre><code>#!/usr/bin/python
  import sys,math
  n = input("enter a number to find the factors   :   ")
  j,flag,b= 0l,False,0l
  for b in xrange(1,n+1):
      a = n + (b*b)
      j = long(math.sqrt(a))
      if a == j*j:
          flag = True
          break
  if flag:
      c = j+b
      d = j-b
      print "the first factor is   :   ",c ,"  and the second factor is   :   ",d
  </code></pre>
  
  <p>when I run this code it is throwing different types of errors for different inputs.</p>
  
  <p>The following is the one kind of input </p>
  
  <pre><code>linux@terminal:~$ ./fermat.py
  enter a number to find the factors   :   544564564545456
  Traceback (most recent call last):
    File "./fermat.py", line 8, in &lt;module&gt;
      for b in range(1,n+1):
  MemoryError
  </code></pre>
  
  <p>This is for second input</p>
  
  <pre><code>linux@terminal:~$ ./fermat.py
  enter a number to find the factors   :   28888888888888888888888888888888888444444444444444444444444
  Traceback (most recent call last):
    File "./fermat.py", line 8, in &lt;module&gt;
      for b in range(1,n+1):
  OverflowError: range() result has too many items
  </code></pre>
  
  <p>And this is for third output</p>
  
  <pre><code>linux@terminal:~$ ./fermat.py
  enter a number to find the factors   :   28888888888888888888888888888888888444444444444444444444444
  Traceback (most recent call last):
    File "./fermat.py", line 8, in &lt;module&gt;
      for b in xrange(1,n+1):
  OverflowError: Python int too large to convert to C long
  </code></pre>
  
  <p>Actually I was writing code for Fermat factorization to find the factors of a given number. And my requirement is even if give a hundred digit number as input it should give the output  for that input number.</p>
  
  <p>Is there any way to get rid this kind of problem?
  I am using Ubuntu with python 2.7.5+</p>