Skip to content

Instantly share code, notes, and snippets.

@evjeny
Created September 30, 2017 16:12
Show Gist options
  • Save evjeny/1a739419e37f5ab28204fa814d3b2c72 to your computer and use it in GitHub Desktop.
Save evjeny/1a739419e37f5ab28204fa814d3b2c72 to your computer and use it in GitHub Desktop.
Solution
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