Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
C++ code to find number to disprove given prime hypothesis
Suppose we have a number n. Let there is a hypothesis "There exists a positive integer n that for each positive integer m number (n·m + 1) is a prime number". We have to find such m as a counter example to disprove this statement.
So, if the input is like n = 12, then the output will be 10, because 12*10 + 1 = 121 which is not prime.
Steps
To solve this, we will follow these steps −
if nExample
Let us see the following implementation to get better understanding −
#includeusing namespace std; int solve(int n){ if (n Input
12Output
10
Advertisements
