I'm trying to find a prime factor of the number 705561475143.
In my code, the function primeFactor() searches for all the factors in a certain integer, plugs them into the function Prime(), which either changes the number into 0 or doesn't change it at all. If the number isn't changed to 0, it's a prime number that should be added to the list.
import math
def Prime(n):
isPrime = False
r = range(2, int(math.sqrt(n)+5))
a = 1
for b in r:
if r[a] >= int(math.sqrt(n)+2):
break
elif n % r[a] != 0:
a += 1
elif n % r[a] == 0 & n != r[a] & n != 1:
n = 0
break
def primeFactor(m):
l = []
for x in range(1, m+1):
if m % x == 0:
if Prime(m) != 0:
l.append(x)
print(l)
However, when I input
> primeFactor(36)
I get
> [1,2,3,4,6,9,12,18,36]
Instead of
> [2,3]
And when I input
> primeFactor(705561475143)
The code cannot give me an answer.