title: prime factorization with large numbers in python
body: <p>whazzup,</p>
  
  <p>Having the following problem, I can't get it fixed.
  Handling with numbers having a length around 5 - 52, I wan't to get their prime factors.
  Using Python, I found the following two algorithms:</p>
  
  <p>I.</p>
  
  <pre><code>def faktorisiere(n):
      l = []  # Lösungsmenge
      # Auf Teilbarkeit durch 2, und alle ungeraden Zahlen von 3..n/2 testen
      for i in chain([2], range(3, n//2 + 1, 2)):
          # Ein Teiler kann mehrfach vorkommen (z.B. 4 = 2 * 2), deswegen:
          while n % i == 0:
              l.append(i)
              print(i)
              n = n // i  # "//" ist ganzzahlige Division und entspricht int(n/i)
          if i &gt; n:  # Alle Teiler gefunden? Dann Abbruch.
              break
      print(l)
  </code></pre>
  
  <p>II.</p>
  
  <pre><code>x = input("Number: ")
  mode = x[-1:]
  x = int(x[:-1])
  if int(x) &lt; 1000000000000:
      faktorisiere(x)
  else:
      if mode == 'f':
          faktorisiere(x)
      rx = int(sqrt(x)) + 1
  
      for i in range(1, rx+1):
          if mode == 'a':
              if x % i == 0:
                  y = int(x/i)
                  print(str(x), "=", i, "*", str(y))
          if mode == 'u':
              if i % 2 != 0:
                  if x % i == 0:
                      y = int(x/i)
                      print(str(x), "=", i, "*", str(y))
  </code></pre>
  
  <p>But the first code is very slow computing numbers like these:
  1917141215419419171412154194191714</p>
  
  <p>The second is working a little faster, but I get wrong outputs and I can't find the mistake in code.
  As an example we take the given number.
  These are the first lines of pythons output: </p>
  
  <ul>
  <li><p>1917141215419419171412154194191714 = 1 *
  1917141215419419143900621852114944 </p></li>
  <li><p>1917141215419419171412154194191714
  = 2 * 958570607709709571950310926057472 </p></li>
  <li>1917141215419419171412154194191714 = 3 *
  639047071806473023947675938062336</li>
  </ul>
  
  <p>But as you can see, these multiplications don't equal the result.
  Is there any mistake in the code?
  Or is it just because of the length of numbers?
  Hope you can help me.</p>
  
  <p>Best wishes,
  TimeMen</p>