2

i'm a beginner in python and started doing problems at projecteuler.net anyway, i'm getting "Python int too large to convert to C long" when using xrange in the code below:

def main():
    num = 600851475143
    r = num/2
    for i in xrange(r, 0, -1):
        if num%i==0:
            print i
            break

tried google this but couldn't understand why python 2.7 is so limited and what can i do about it.

edit: tried using itertools.count without understanding too much how about it and it crashed my cmd:

import itertools

def main():
num = 600851475143
r = num/2
for i in itertools.count(r, -1):
    if num%i==0:
        print i
        break
galah92
  • 3,621
  • 2
  • 29
  • 55

0 Answers0