Advertisement
qekaqeka

Code

Mar 29th, 2023
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | Source Code | 0 0
  1. import math
  2. import time
  3.  
  4. start = time.time()
  5.  
  6. def f(n):
  7. c = 1
  8. Min1 = -1
  9. Min2 = -1
  10. sqrt = n**0.5
  11. e = n % 2 == 1
  12.  
  13. if e:
  14. c += 1
  15. if e and (sqrt != int(sqrt) or sqrt % 2 != 1):
  16. return
  17.  
  18. sqrt = int(sqrt)
  19. if e:
  20. c += 1
  21. for a in range(3, math.ceil(sqrt), 2):
  22. if n % a == 0:
  23. c += 2
  24. if Min1 == -1:
  25. Min1 = a
  26.  
  27. if c > 5:
  28. return
  29.  
  30. else:
  31. for a in range(2, sqrt + 1):
  32. if n % a == 0:
  33. j = n // a
  34. if j % 2 == 1:
  35. c += 1
  36. if Min1 == -1:
  37. Min1 = j
  38. elif a % 2 == 1:
  39. c += 1
  40. if Min2 == -1:
  41. Min2 = a
  42. if c > 5:
  43. return
  44.  
  45. if c == 5:
  46. if Min1 == -1:
  47. Min1 = 88_888_889
  48. if Min2 == -1:
  49. Min2 = 88_888_889
  50.  
  51. print(n, min(Min1, Min2))
  52.  
  53. for i in range(77_777_777, 88_888_888 + 1):
  54. f(i)
  55.  
  56. print(time.time() - start)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement