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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started