import math
# Function to check if a number is prime
def isPrime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
limit = int(math.sqrt(n))
for i in range(5, limit + 1, 6):
if n % i == 0 or n % (i + 2) == 0:
return False
return True
# Function to find the two prime factors A and B, returned as a tuple (A, B)
def findAB(N):
limit = int(math.sqrt(N))
for i in range(2, limit + 1):
if N % i == 0:
j = N // i
if isPrime(i) and isPrime(j):
return (i, j)
return (-1, -1) # No prime factors found
def main():
N = 12349
result = findAB(N)
A, B = result
if A != -1:
print("A =", A, ", B =", B)
else:
print("Not found.")
main()
"""
run:
A = 53, B = 233
"""