Given a number x, Find y (y > 0) such that x*y + 1 is not a prime.
Input : 2 Output : 4 Input : 5 Output : 3
x*(x-2) + 1 = (x-1)^2 which is not a prime.
For x > 2, y will be x-2 otherwise y will be x+2
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.
- Find coordinates of a prime number in a Prime Spiral
- Find the minimum number to be added to N to make it a prime number
- Program to find the Nth Prime Number
- Find the position of the given Prime Number
- Program to find the next prime number
- Find largest prime factor of a number
- Find all the prime numbers of given number of digits
- Find sum of a number and its maximum prime factor
- Find prime number K in an array such that (A[i] % K) is maximum
- Find a sequence of N prime numbers whose sum is a composite number
- Find the number of primitive roots modulo prime
- Find Largest Special Prime which is less than or equal to a given number
- Analysis of Different Methods to find Prime Number in Python
- Find third number such that sum of all three number becomes prime
- Quick ways to check for Prime and find next Prime in Java
- Check if a number is Prime, Semi-Prime or Composite for very large numbers
- 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
- Check if a prime number can be expressed as sum of two Prime Numbers
- Number of factors of very large number N modulo M where M is any prime number
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.