Question: Recall that a prime number is an integer that is evenly divisible only by itself and 1. A Sophie Germain prime (named after the French

 Recall that a prime number is an integer that is evenly

Recall that a prime number is an integer that is evenly divisible only by itself and 1. A Sophie Germain prime (named after the French mathematician) is a prime number p such that (2p + 1) is also prime. For example, 5 is a Sophie Germain prime because it is prime, and 11 (i.e., 2 * 5 + 1) is also prime. Write a C program that prompts the user to enter a positive integer value n. Your program should identify (calculate) and print the nth Sophie Germain prime (it has been conjectured that there are an infinite number of Sophie Germain primes, but you may assume for this assignment that n will never exceed 2500). In other words, if the user enters 12 for n, your program should print out the 12th Sophie Germain prime (and only that value). DO NOT SIMPLY PRE-CALCULATE AND HARDCODE THE FIRST 2500 SOPHIE GERMAIN PRIMES INTO YOUR PROGRAM. Your first step, of course, is to identify general prime numbers; without them, you can't find any of the Sophie Germain primes. Start by defining a C function with the following header (you can change the name, of course): int isPrime (int number) This function should return 1 (true) if number is prime, and 0 (false) if it is not. Inside the function, use a loop to test all of the integers from 2 through (number-1) to see if they divide number evenly; if any of them do, then number cannot be prime. Use isPrime () inside a loop in main() to examine successive integer values for primeness. Each time you find a prime integer, check to see if it is also a Sophie Germain prime and increment your count if it is. Once your counter reaches the user-specified value, end the loop and print out that integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!