Automatic commit performed through alias...
This commit is contained in:
30
problems/003_problem.py
Normal file
30
problems/003_problem.py
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
# Problem 3:
|
||||
#
|
||||
# The prime factors of 13195
|
||||
# are 5, 7, 13 and 29.
|
||||
#
|
||||
# What is the largest prime
|
||||
# factor of the number 600851475143 ?
|
||||
#
|
||||
import decorators
|
||||
|
||||
def treat_evens(n):
|
||||
mod_is_zero = True
|
||||
dividend = 2
|
||||
while mod_is_zero:
|
||||
num = n/dividend
|
||||
mod_is_zero = 0 == n%dividend
|
||||
dividend *= 2
|
||||
print("{}".format(num))
|
||||
return num
|
||||
|
||||
@decorators.function_timer
|
||||
def main():
|
||||
|
||||
orig = 600851475143
|
||||
num = treat_evens(orig)
|
||||
|
||||
print("Highest prime of 600851475143 is {}".format(num))
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user