def FindingTwoPrimes(n, p1, p2):
p1 = 0
p2 = 0
n = 0
primeList = []
for num in range(1,101):
if all(num%i!=0 for i in range(2,num)):
primeList.append(num)
print (primeList)
print ("Length of Primelist = ", len(primeList))
lengthOfPrimelist = len(primeList)
p1 = primeList[random.randint(0,lengthOfPrimelist)]
p2 = primeList[random.randint(0,lengthOfPrimelist)]
n = p1 * p2
print ("p1 =", p1)
print ("p2 =", p2)
return n
return p1
return p2
FindingTwoPrimes(n, p1, p2)
print(p1, p2, n)
So above is a function that will find two primes that I will use in the method of the public key encryption system. However, when I run the function it returns p1, p2 and n back as 0. Why is this and how do I solve it? Also, any methods to make this code more efficient would be appreciated :-)
return (n, p1, p2)and then get them as:n, p1, p2 = FindingTwoPrimes(n, p1, p2)