Given a positive integer N, the task is to check if N is a strong prime or not.
In number theory, a strong prime is a prime number that is greater than the arithmetic mean of nearest prime numbers i.e next and previous prime numbers.
First few strong prime numbers are 11, 17, 29, 37, 41, 59, 67, 71, …
A strong prime Pn can be represented as-
where n is its index in the ordered set of prime numbers.
Input: N = 11
11 is 5th prime number, the arithmetic mean of 4th and 6th prime number i.e. 7 and 13 is 10.
11 is greater than 10 so 11 is a strong prime.
Input: N = 13
13 is 6th prime number, the arithmetic mean of 5th (11) and 7th (17) is (11 + 17) / 2 = 14.
13 is smaller than 14 so 13 is not a strong prime.
- If N is not a prime number or it is the first prime number i.e. 2 then print No.
- Else find the primes closest to N (one on the left and one on the right) and store their arithmetic mean in mean.
- If N > mean then print Yes.
- Else print No.
Below is the implementation of the above approach:
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program to check Strong Number
- Check if a number is Prime, Semi-Prime or Composite for very large numbers
- Quick ways to check for Prime and find next Prime in Java
- Check if a prime number can be expressed as sum of two Prime Numbers
- Check whether the sum of prime elements of the array is prime or not
- Check n^2 - m^2 is prime or not
- Check if two numbers are co-prime or not
- Check if Matrix sum is prime or not
- Check if N is a Factorial Prime
- Print all Strong numbers less than or equal to N
- Check whether a number is Good prime or not
- Check if N is a Balanced Prime number or not
- Check if N is a Weak Prime number or not
- Check a number for Permutable Prime
- Check if the first and last digit of number N is prime and their sum is less than K
- Check if the given string is vowel prime
- C Program to Check Whether a Number is Prime or not
- Check whether the given number is Wagstaff prime or not
- Check if a number is Full Prime
- Check whether N is a Dihedral Prime Number or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.