Question
(A prime number, p, is called a Sophie Germain Prime if both p and 2p+1 are primes. The first few Sophie Germain Primes are 2,
(A prime number, p, is called a Sophie Germain Prime if both p and 2p+1 are primes. The first few Sophie Germain Primes are 2, 3, 5, 11, 23, 29, 41, 53, 83, 89, 113, 131, etc. It is not known whether there are an infinite number of such primes. The largest known Sophie Germain prime is 79911 decimal digits long)
Write a program to investigate the distribution of Sophie Germain Primes.Write a C program that reads an integer number, say r. It then computes and outputs a table with the number of Sophie Germain Primes less than 10, 10^2, 10^3, 10^r.
For example if r is 5 it should output:
3
10
37
190
1171
Test the program for different values for r.
To simplify the problem we could split it into smaller pieces by defining functions. One function that would be useful would be a function called isPrime. That function would take an integer argument, n, and return 1 if n is a prime number and 0 otherwise. Another useful function would be countValues which takes an integer argument, say and returns the number of Sophie Germain primes less than k.
The program must actually test numbers for primality and count the number of primes that are Sophe Germain primes. It must not just output the final results by obtaining them from other sources.
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