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
- Print all Strong numbers less than or equal to N
- 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 if a number is Prime, Semi-Prime or Composite for very large numbers
- Find coordinates of a prime number in a Prime Spiral
- Prime numbers after prime P with sum S
- Sum of each element raised to (prime-1) % prime
- Print the nearest prime number formed by adding prime numbers to N
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Print prime numbers with prime sum of digits in an array
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Print all numbers whose set of prime factors is a subset of the set of the prime factors of X
- Sum of prime numbers without odd prime digits
- Count occurrences of a prime number in the prime factorization of every element from the given range
- Absolute difference between the XOR of Non-Prime numbers and Prime numbers of an Array
- Permutation of first N positive integers such that prime numbers are at prime indices
- Permutation of first N positive integers such that prime numbers are at prime indices | Set 2
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.