Automatic commit performed through alias...
This commit is contained in:
@@ -8,26 +8,50 @@
|
|||||||
# factor of the number 600851475143 ?
|
# factor of the number 600851475143 ?
|
||||||
#
|
#
|
||||||
import decorators
|
import decorators
|
||||||
|
import time
|
||||||
|
|
||||||
def treat_evens(n):
|
#def treat_evens(n):
|
||||||
mod_is_zero = True
|
# mod_is_zero = True
|
||||||
done = True
|
# done = True
|
||||||
dividend = 2
|
# dividend = 2
|
||||||
while mod_is_zero or done:
|
# while mod_is_zero or done:
|
||||||
done = dividend == n
|
# done = dividend == n
|
||||||
num = n/dividend
|
# num = n/dividend
|
||||||
mod_is_zero = 0 == n%dividend
|
# mod_is_zero = 0 == n%dividend
|
||||||
dividend *= 2
|
# dividend *= 2
|
||||||
print("{}".format(num))
|
# print("{}".format(num))
|
||||||
return num
|
# return num
|
||||||
|
|
||||||
|
# Create function that finds the next
|
||||||
|
# prime number when supplied with an
|
||||||
|
# intitial integer.
|
||||||
|
|
||||||
|
def return_next_prime(start_n,max_n):
|
||||||
|
|
||||||
|
start_n += 1
|
||||||
|
for candidate in range(start_n,max_n):
|
||||||
|
notPrime = False
|
||||||
|
|
||||||
|
if candidate in [0,1,2,3]:
|
||||||
|
yield candidate
|
||||||
|
|
||||||
|
for dividend in range(2,candidate):
|
||||||
|
|
||||||
|
if candidate%dividend == 0:
|
||||||
|
notPrime = True
|
||||||
|
|
||||||
|
if not notPrime:
|
||||||
|
yield candidate
|
||||||
|
|
||||||
@decorators.function_timer
|
@decorators.function_timer
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
#orig = 600851475143
|
orig = 600851475143
|
||||||
orig = 8
|
start = 3
|
||||||
num = treat_evens(orig)
|
returned_prime = start
|
||||||
|
while returned_prime < orig:
|
||||||
print("Highest prime of 600851475143 is {}".format(num))
|
returned_prime = return_next_prime(start,orig).__next__()
|
||||||
|
print("A PRIME HAS BEEN FOUND!!!! ... {}".format(returned_prime))
|
||||||
|
start = returned_prime
|
||||||
|
|
||||||
main()
|
main()
|
||||||
Reference in New Issue
Block a user