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:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- 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
- Print all Strong numbers less than or equal to N
- Check if Matrix sum is prime or not
- Check if two numbers are co-prime or not
- Check if N is a Factorial Prime
- Check if the given string is vowel prime
- Check if a number is a Pythagorean Prime or not
- Check if a number is Quartan Prime or not
- C Program to Check Whether a Number is Prime or not
- Check for an array element that is co-prime with all others
- Check whether a number is circular prime or not
- Check a number for Permutable Prime
- Check if a number is Primorial Prime or not
- Check whether N is a Dihedral Prime Number or not
- Check whether the given numbers are Cousin prime 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.