tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,12 @@
|
|||
public static boolean prime(long a){
|
||||
if(a == 2){
|
||||
return true;
|
||||
}else if(a <= 1 || a % 2 == 0){
|
||||
return false;
|
||||
}
|
||||
long max = (long)Math.sqrt(a);
|
||||
for(long n= 3; n <= max; n+= 2){
|
||||
if(a % n == 0){ return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
public static boolean prime(int n) {
|
||||
return !new String(new char[n]).matches(".?|(..+?)\\1+");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue