Write a program to print all sophie germain number less than n. A prime number p is called a sophie prime number if 2p+1 is also a prime number. The number 2p+1 is called a safe prime. For example 11 is a prime number and 11*2 + 1 = 23 is also a prime number so, 11 is sophie germain prime number . The first few Sophie German prime numbers are 2, 3, 5, 11, 23, 29, 41, 53, 83, 89, 113, 131, 173, 179 ..
Input : 25 Output : 2 3 5 11 23
Here is the program to print sophie germain number below n .
The solution of this is simple . To obtain all the sophie numbers below n we will make a loop till n and for each number in the loop we can check that whether that number and (2*number + 1), both are prime or not and for checking this we have used Sieve of Erastothenes method.
Below is the implementation of this approach.
2 3 5 11 23
Application of Sophie Prime Numbers :
1. It is used in cryptography as safe primes become the factors of a secret key in RSA cryptosystem.
2. In the first version of AKS Primality Test, it is used to lower the worst case complexity .
3. It is used in the generation of Pseudo Random Number .
- Count occurrences of a prime number in the prime factorization of every element from the given range
- Print the nearest prime number formed by adding prime numbers to N
- Quick ways to check for Prime and find next Prime in Java
- Print prime numbers with prime sum of digits in an array
- Check if a prime number can be expressed as sum of two Prime Numbers
- Find coordinates of a prime number in a Prime Spiral
- Check whether the sum of prime elements of the array is prime or not
- Sum of each element raised to (prime-1) % prime
- Sum of prime numbers without odd prime digits
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Print all numbers whose set of prime factors is a subset of the set of the prime factors of X
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
- Prime numbers after prime P with sum S
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Sum of the first N Prime numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : manishshaw1