Automatic commit performed through alias...
This commit is contained in:
@@ -15,7 +15,17 @@ import time
|
||||
# prime number when supplied with an
|
||||
# intitial integer.
|
||||
|
||||
def return_next_prime(start_n,max_n):
|
||||
def primes_gen(start_n,max_n):
|
||||
"""
|
||||
Returns a generator object, containing the
|
||||
primes inside a specified range.
|
||||
|
||||
primes_gen(start_n,max_n)
|
||||
|
||||
param 'start_n': Previous prime.
|
||||
param 'max_n': Maximum
|
||||
|
||||
"""
|
||||
|
||||
start_n += 1
|
||||
for candidate in range(start_n,max_n):
|
||||
@@ -37,18 +47,20 @@ def main():
|
||||
|
||||
result1 = orig = 600851475143
|
||||
returned_prime = prime_start = 2
|
||||
factor_list = []
|
||||
prime_factor_list = []
|
||||
|
||||
while returned_prime < orig ** 0.5 and returned_prime<result1:
|
||||
returned_prime = return_next_prime(prime_start,orig).__next__()
|
||||
|
||||
|
||||
returned_prime = primes_gen(prime_start,orig).__next__()
|
||||
|
||||
result2 = result1/returned_prime
|
||||
if result1%returned_prime == 0:
|
||||
#print(" {} / {} = {}".format(result1,returned_prime,result2))
|
||||
factor_list.append(returned_prime)
|
||||
prime_factor_list.append(returned_prime)
|
||||
result1 = result2
|
||||
prime_start = returned_prime
|
||||
|
||||
print("This highest prime factor of {} is {} ... ".format(orig,max(factor_list)))
|
||||
print("This highest prime factor of {} is {} ... ".format(orig,max(prime_factor_list)))
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user