Automatic commit performed through alias...
This commit is contained in:
@@ -7,21 +7,10 @@
|
||||
# What is the largest prime
|
||||
# factor of the number 600851475143 ?
|
||||
#
|
||||
|
||||
import decorators
|
||||
import time
|
||||
|
||||
#def treat_evens(n):
|
||||
# mod_is_zero = True
|
||||
# done = True
|
||||
# dividend = 2
|
||||
# while mod_is_zero or done:
|
||||
# done = dividend == n
|
||||
# num = n/dividend
|
||||
# mod_is_zero = 0 == n%dividend
|
||||
# dividend *= 2
|
||||
# print("{}".format(num))
|
||||
# return num
|
||||
|
||||
# Create function that finds the next
|
||||
# prime number when supplied with an
|
||||
# intitial integer.
|
||||
@@ -46,12 +35,20 @@ def return_next_prime(start_n,max_n):
|
||||
@decorators.function_timer
|
||||
def main():
|
||||
|
||||
orig = 600851475143
|
||||
start = 3
|
||||
returned_prime = start
|
||||
while returned_prime < orig:
|
||||
returned_prime = return_next_prime(start,orig).__next__()
|
||||
print("A PRIME HAS BEEN FOUND!!!! ... {}".format(returned_prime))
|
||||
start = returned_prime
|
||||
result1 = orig = 600851475143
|
||||
returned_prime = prime_start = 2
|
||||
factor_list = []
|
||||
|
||||
while returned_prime < orig ** 0.5 and returned_prime<result1:
|
||||
returned_prime = return_next_prime(prime_start,orig).__next__()
|
||||
|
||||
result2 = result1/returned_prime
|
||||
if result1%returned_prime == 0:
|
||||
#print(" {} / {} = {}".format(result1,returned_prime,result2))
|
||||
factor_list.append(returned_prime)
|
||||
result1 = result2
|
||||
prime_start = returned_prime
|
||||
|
||||
print("This highest prime factor of {} is {} ... ".format(orig,max(factor_list)))
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user