Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. #Find the largest prime factor of 600851475143
  2.  
  3. #Here's an attempt at bruteforcing the problem, wish me luck.
  4.  
  5.  
  6. #initializing some variables for use
  7.  
  8. Number = 600851475143
  9. numCheck = (Number / 2) + 1
  10. factorCheck = 0
  11. highestFound = 0
  12.  
  13. def checkPrimeness(num):
  14.     uBound = int((num ** 0.5) + 1)
  15.     lBound = 1
  16.     check = lBound
  17.     while check < uBound:
  18.         check = check + 1
  19.         if num % check == 0:
  20.             return 0
  21.     return 1
  22.        
  23.  
  24. while numCheck > 0:
  25.     print numCheck
  26.     numCheck = numCheck - 1
  27.     if Number % numCheck == 0:
  28.         if checkPrimeness(numCheck) == 1:
  29.             print numCheck
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement