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