Project Euler #3 in Python
<p>For reference:</p>

<blockquote>
  <p>The prime factors of 13195 are 5, 7, 13 and 29.
  What is the largest prime factor of the number 600851475143 ?</p>
</blockquote>

<p>So I solved Project Euler's third problem after a fair bit of tinkering. Not the sleekest of codes, but it mostly works.</p>

<pre><code>import math
import itertools

def is_prime(x):
    # Checks if the factor is prime. If not, breaks and looks at the next one
    split_tuple = math.modf(math.sqrt(x))
    max_prime_div_possible = int(split_tuple[1])
    prime = True
    for i in range(2, max_prime_div_possible+1):
        if x % i == 0:
            prime = False
            break
        else:
            pass
    return prime

def factor_me(x):
    # Creates a list of all factors of a number
    factors = []
    split_tuple = math.modf(math.sqrt(x))
    max_pf_possible = int(split_tuple[1])
    for i in xrange(2, max_pf_possible+1):
        if x % i == 0:
            factors.append(i)
            x = x/i
        else:
            pass

    # Checks each factor for prime-ity, and if it is, sets it as the max prime factor.
    for j in factors:
        if is_prime(j) == True:
            max_prime_factor = j
        else:
            pass
    return max_prime_factor


print factor_me(600851475143) # works correctly
print factor_me(6008514751435) # fails
</code></pre>

<p>The thing is, even though the code works correctly with both the example test and proposed problem, if another digit is added to the number to be factorized, the code breaks. To give an example to make myself clear, take 6008514751435.<br>
According to Wolfram Alpha, this factors into 5, 7 and 171671850041. However, according to my code, the largest factor is 7. So, well, I'm stumped. Any suggestions?</p>