Created
April 28, 2018 14:29
-
-
Save seanballais/04c8d240fa7a9eb5d44759410d2d18a7 to your computer and use it in GitHub Desktop.
Obtaining the Prime Factors of a Semiprime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def obtain_pq(n): | |
p = 0.1 | |
k = math.ceil(math.sqrt(n)) | |
while not p.is_integer(): | |
p = k - math.sqrt((k ** 2) - n) | |
k += 1 | |
q = int(n / p) | |
p = int(p) | |
return p, q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment