-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPolandBallandHypothesis.cs
38 lines (31 loc) · 1.18 KB
/
PolandBallandHypothesis.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis:
"There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number".
Unfortunately, PolandBall is not experienced yet and doesn't know that his hypothesis is incorrect. Could you prove it wrong?
Write a program that finds a counterexample for any n.
Input
The only number in the input is n (1 ≤ n ≤ 1000) — number from the PolandBall's hypothesis.
Output
Output such m that n·m + 1 is not a prime number.
Your answer will be considered correct if you output any suitable m such that 1 ≤ m ≤ 103. It is guaranteed the the answer exists.
*/
using System;
class PolandBallandHypothesis
{
static void Main(string[] args)
{
int n = Convert.ToInt32(Console.ReadLine());
for (int m = 1; m <= 1000; m++)
{
for (int j = 1; j <= n; j++)
{
int num = (n * m + 1);
if (num%j==0 && j!=1 && num!=j)
{
Console.WriteLine(m);
return;
}
}
}
}
}