Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

isprime check formula java

  static boolean isPrime(int n){
        boolean result=true;
        if(n <= 1) return false;
        for(int i = 2; i <= n/2; i++){
            if(n % i == 0){
                result = false; //if some number divides it, then prime=false;
                break;
            }
        }
        return result;
    }
Comment

isprime java

static boolean isPrime(int n){
	for (int i = 2; i <= Math.sqrt(n); i++)
		if (n % i == 0) return false;
	return n > 1;
}
Comment

PREVIOUS NEXT
Code Example
Java :: gson java maven dependency script google json repository 
Java :: bukkit delayed task 
Java :: javafx button color 
Java :: how to loop through code 3 times java 
Java :: java pause 1 second 
Java :: generate random password in java 
Java :: loop through dictionary java 
Java :: java jcombobox get selected item 
Java :: simpleListView = (ListView) findViewById(R.id.simpleListView) explain 
Java :: full screen android java 
Java :: java try catch integer.parseint 
Java :: string to double java exception 
Java :: cast long to string java 
Java :: exit app android 
Java :: spring boot id auto generated 
Java :: java remove non numbers from string 
Java :: android hide soft keyboard 
Java :: how to parse double upto 2 decimal in java 
Java :: How do you print duplicate characters from a string? 
Java :: Java get fps 
Java :: set location of a label java 
Java :: update value in hashmap java 
Java :: java split first occurrence 
Java :: StringBuilder java pop back 
Java :: complicated average java code 
Java :: smaller elements on right hand side leetcode 
Java :: appcompatdelegate.setdefaultnightmode(appcompatdelegate.mode_night_yes) not working 
Java :: jpa validation string only number 
Java :: how to create javafx project in eclipse 
Java :: rdd. map with condition 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =