A number is said to be sandwiched between primes if the number just after it and the number just before are Prime numbers. So, a sandwiched number is between two prime numbers.
Given a number n, we need to check whether this number is sandwiched between primes or not.
Input : 642 Output : Yes Explanation : 641 and 643 are both prime numbers Input : 6 Output : Yes Explanation : 5 and 7 both are prime numbers Input : 9 Output : No Explanation : 8 and 10 both are non-prime numbers
The idea is simple, we check if n-1 and n-2 are prime numbers.
642 : Yes 9 : No
- Check whether given three numbers are adjacent primes
- Check if the sum of primes is divisible by any prime from the array
- Check if an integer can be expressed as a sum of two semi-primes
- Length of largest sub-array having primes strictly greater than non-primes
- Count primes that can be expressed as sum of two consecutive primes and 1
- Count number of primes in an array
- Number of primes in a subarray (with updates)
- Minimum number of single digit primes required whose sum is equal to N
- Rearrange the array to maximize the number of primes in prefix sum of the array
- Count the number of primes in the prefix sum array of the given array
- Prime points (Points that split a number into two primes)
- Check if a number is divisible by all prime divisors of another number
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Circular primes less than n
- Palindromic Primes
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.