feat(solution): problem #3

main
steven 2023-07-31 13:47:56 -04:00
parent 838417781a
commit a7f09bc13c
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import math
largestPrimeFactor = 1
toBeFactored = 600851475143
def is_prime(maybeprime):
for i in range(2, math.floor(math.sqrt(maybeprime) + 1)):
if maybeprime % i == 0:
return False
return True
for i in range(2, math.floor(math.sqrt(toBeFactored) + 1)):
if is_prime(i) and toBeFactored % i == 0:
largestPrimeFactor = i
print("The largest prime factor of " + str(toBeFactored) + " is: " + str(largestPrimeFactor))