{{#items}}

{{text}}

{{/items}} {{ctaText}}

{{#items}} {{/items}}

showing results for - "isprime check formula java"

Fredrick

10 Mar 2020

```
1 static boolean isPrime(int n){
2 boolean result=true;
3 if(n <= 1) return false;
4 for(int i = 2; i <= n/2; i++){
5 if(n % i == 0){
6 result = false; //if some number divides it, then prime=false;
7 break;
8 }
9 }
10 return result;
11 }
```

similar questions

how to get prime number in javapal prime number program in javahow to find prime and composite numbers in java on an arrayjava prime numbersnth prime number javaprint prime numbers in javaprime number between two numbers in javahow to check number format exception in javagenerate all prime number less than n javachecking if a given integer is a prime number javagenerate all prime number less than n java 28fastest method 29program to check whether the number is prime or not in javasum of prime numbers in a digit in javaprime number javajava program to print prime numbers in a given rangejava program to find prime number between 1 and 100primenumbers javahow to check if number prime in javaprime check jabaprime in javaprime number program in javajava program to display prime numbers from 1 to 100prime check java your answer for

you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content

please ensure to add code which is syntactically corrent and executes properly

ask question on maxinterview

you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content

please be clear, to the point and respectful