Question: In some cryptographic applications, it is necessary to use a special kind of prime numbers called safe primes. These are primes of the form q
In some cryptographic applications, it is necessary to use a special kind of prime numbers called safe primes. These are primes of the form q = 2p + 1, where p is also prime. The integer p is known as a Sophie Germain prime. Write a function that takes in an integer n, and returns the first safe prime, such that p > n. Your function should output a tuple (p, q), comprising the Sophie Germain prime, and the safe prime. def safePrime(n): # Provide a correct implementation for this function return (0, 0)
test
k = (0,0) result = [] for i in range(7): k = safePrime(k[0]) result.append(k) expected = [(2, 5), (3, 7), (5, 11), (11, 23), (23, 47), (29, 59), (41, 83)] print "The first 7 safe primes:\t\t", result check(result, expected)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
