In: Computer Science
Write a Python function next_Sophie_Germain(n), which on input a positive integer n return the smallest Sophie Germain prime that is greater or equal to n.
def Isprime(n):
if n==2:
return 1
flag = 1
for i in range(2,n-1):
if n % i == 0:
flag = 0
break
return flag;
def next_Sophie_Germain(n):
while True:
if Isprime(n) and Isprime(2*n + 1):
return n
n = n + 1
print(next_Sophie_Germain(11))
print(next_Sophie_Germain(4))
print(next_Sophie_Germain(42))
==================================
SEE OUTPUT
Thanks, PLEASE COMMENT if there is any concern. PLEASE UPVOTE