I have a file of numbers that i need the prime factorization for. so it should look like: "250,000,001 = 148,721 * 41 * 41" on the output. my code so far is:
factors = [2, 5, 7, 9, -1]
def primeFactors(x, primes):
myList = []
myFile = open('ten.txt', 'r', encoding = 'utf-8')
for x in myFile:
x = (int(x) % f for f in factors)
myList.append(x)
print(myList)
primeFactors(open('ten.txt', 'r', encoding = 'utf-8'), factors)
With the output being (generator object (genexpr) at 0x100647870)
what do i need to do to even get the factors listed out?
Edit i guess i should mention that this is completely wrong i realize that. but here i made some edits to my code. I am intending to print out the factorization using factors under 10,000,000.
factors = [2, 3, 5, 7, 11, -1]
n = 10000000
primes = list()
multiples = set() #creates list of primes out of 10,000,000
for i in range(2, n+1):
if i not in multiples:
primes.append(i)
multiples.update(range(i*i, n+1, i))
def primeFactors(x, primes):
factors = [f for f in primes] #trying to get the factorization for 25,000,001
if x % factors == 0:
return primes
primeFactors(25000001, primes)
the problem is that i do not know how to get my x value, 25000001 to be divided one by one until it comes out without a remainder into the aforementioned factorization in the first post.
does that make sense?