Created
September 30, 2017 16:12
-
-
Save evjeny/1a739419e37f5ab28204fa814d3b2c72 to your computer and use it in GitHub Desktop.
Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
/** | |
* Created by evjeny | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int a = scanner.nextInt(); | |
a += (a%2==0?1:2); | |
while(true) { | |
if(iss(a)) { | |
print(a); | |
break; | |
} | |
a+=2; | |
} | |
} | |
private static boolean iss(int todo) { | |
boolean sm = true; | |
int len = todo/2; | |
for(int i = 1; i<=len; i+=2) { | |
if(i!=1&&todo%i==0) { | |
sm = false; | |
break; | |
} | |
} | |
return sm; | |
} | |
private static void print(Object todo) { | |
System.out.print(todo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment