prime check java

Solutions on MaxInterview for prime check java by the best coders in the world

showing results for - "prime check java"
Ezio
12 Jul 2019
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++){ //n/2 because the largest factor of any number is either it's half or less than it
5            if(n % i == 0){
6                result = false; //if some number divides it, then prime=false;
7                break;
8            }
9        }
10        return result;
11    }
Graeme
07 Jul 2019
1public class Prime {
2
3    public static void main(String[] args) {
4
5        int num = 29;
6        boolean flag = false;
7        for(int i = 2; i <= num/2; ++i)
8        {
9            // condition for nonprime number
10            if(num % i == 0)
11            {
12                flag = true;
13                break;
14            }
15        }
16
17        if (!flag)
18            System.out.println(num + " is a prime number.");
19        else
20            System.out.println(num + " is not a prime number.");
21    }
22}
Jeanne
13 Jun 2020
1public class PrimeNumberInJava
2{
3   public static void main(String[] args)
4   {
5      int a, b = 0, flag = 0;
6      int number = 17;
7      b = number / 2;
8      if(number == 0 || number == 1)
9      {
10         System.out.println(number + " is not prime number");
11      }
12      else
13      {
14         for(a = 2; a <= b; a++)
15         {
16            if(number % a == 0)
17            {
18               System.out.println(number + " is not prime number.");
19               flag = 1;
20               break;
21            }
22         }
23         if(flag == 0)
24         {
25            System.out.println(number + " is prime number.");
26         }
27      }
28   }
29}
queries leading to this page
code java prime numberjava check if a number is primehow to find the prime number in javawap to print prime number in javaprime numbers till the number in javahow to check prime or not in javajava to check if its a prime nuumber or notjava program to determine if a number is primedetermine if a number is prime algorithm javajava program to see if number is prime or notprimenumber java programmeall pali prime number in javaprime number algorithm javawrite a function to check whether a number is prime or not in javahow to check if a number is prime in javawrite a program to check if a given number is prime or not show left side no prime in javacheck if prime javahow to check number is prime or not in javafind a prime number javaprime function javaprime genrator javacheck a number is prime in javaprime number math program javan prime number or not in javacheck given number is prime or not in javacheck number is prime or not in javajava get write prime numbershow to check if number is pime javaprime numbers in javacheck prime javaprime check in java codeprime java rocresiajavacheck prime numberfind prime number or not in javajava prime numberprogram to check whether a number is prime javahow to check for prime in javajava method to check for prime numbershow to check prime no in javajava program to determine if primefunction to check if a number is primein javajava program to display prime numbersjava program to see if a number is prime numberbest java program to find prime number or nothow to find the number is prime or not javapal prime number program in java gfghow to check for prime javahow to check if a number is a prime in java in 1 linewrite a java programme to print a number is prime or nothow to check a number is prime or not in javajava program check if number is prime forfind if a number is prime or not in javawrite a java program to check if a given number is prime or notprime number finding in javacheck a number is prime or not in javacalculate prime numbers in javahow to find a number is prime or not in javaoolean prime in javacheck if number is prime or not javajava program to know if given number is primehow to check if 1 is prime javafinding the prime number java to check if a number is prime javahow to determine if a number is prime javaa number is prime or not in javaprime checker program javajava prime nocheck number is prime javajava calclulate if number is primeprime nuber in javafind prime number javafind primes in javabest prime number program in javagenerate prime numbers javahow to check for a prime number in javahow to check if number prime in javajava check if an integer is a prime number recursivejava program to check for prime numberprint prime no in javawrite a program to check if given number is prime number in javahow to find prime numbers in javaprime numbers using javacheck if number is prime in javacheck if the number is prime javaprime number logic javajava program to check given number is prime or notcheck prime number in javapimenumber javaoptimal way to check wheter given number is prime or not in javawrite a java program to check whether given number is prime or not write a java program to check prime numberprime number java program simplejava program to find prime number or notjava check its a prime or notjava code to check for a prime numberhow to determine if number is prime javaprint prime numbers in javajava integer prime numbercheck if it 27s a prime number javahow to check prime number in javaprime no javaif prime or not javajava find prime numbercan java tell if a number is primecheck if a number is prime java programhow to find is a number is prime in javatest for prime number javajava check prime number with testsgetting a set of prime numbers javahow to check if prime in javaprime number javajava program to check prime numberprime numbers java for loopgood algo to find prime number in javawrite a java program to print prime numbersjava code for prime number checkingjava how to get prime or compositecheck whether a no is prime or not in javacheck whether number is prime or not in javahow to check for prime number in javajava check primeefficient way to find prime numbers in javacheck whether prime or not in javacheck if a number is a prime number javaprime no in javahow to print a number and see if it is prime or not in javajava code for prime numbersprime check javahow to find prime numbers javajava program to check whether a number is prime or not using for loop forhow to determine if a number is prime in javacheck if the int is a prime number in javahow to check wheater a number is prime or not javahow to find primes javafind if number is prime javahow to check prime in string javajava is prime o 281 29java code for prime number checking from userfind if the number is prime number java the stupid wayfind the prime number for given array in javacode to check if a number is prime in javahow to test if a number is prime in javaprime or not in javajava function to check prime numberjava find if a number is primecheck if no is prime or not in javahow to check if a number is a prime in java in o 281 29can void check if a number is prime in java prim function javaprime check function in javaprime number funtion javatest if a number is prime javahow to check if prime number javajava prime nucheck whether number is prime or not javais prime function javahow to write code for prime numbers in javajava is primeprint prime number in javajava program to check if a number is primefind the given number is prime or not in javahow to find prime number in array javato find prime number in java in set of elementshow to find whether the number is prime or composite in javawrite a program to find out if a number is prime javafastest way to calculate prime or not in javahow to find number of prime numbers using javaprime detecting javacheck whether prime number java programhow to checl if a number is prime javajava prime number programjava program to check whether number is prime or not checking if a number is prime javajava how to check if a number is primeprogram to check for prime numbers in javawhy 4 is prime number in javahow to check if a number is prime java for loopjava primeprogram to find prime numbers javajava program to find whether a number is prime or notisprime javamethod to generate prime number in java1 you 27ve to check whether a given number is prime or not javajava program to find prime numbers in an arrayjava check for prime numberwrite a program to check if a given number is prime or not in javanumber is prime or not javaprime logic javatest for prime number in javacheck for prime number javajava best way to determine if number is primecheck whether numbers are prime javajava program to find a number is prime or notisprime method javadetetc prime number javahow to check number is prime javahow to find if a number is prime in javajava prime checkprime numbers java programprime number calculation in javawrite a program to find a given number is prime number or not javajava code to check a number is primeprimary number in javainput any number to check prime in javajava find prime number methodjava code to check the the number is prime numberjava program to check whether number is prime or notfind prime number in javaprimary number javaprogramming with java prime java is prime functionnumber is prime or not in javahow to find prime in javacheck prime number in java using for loopfind if a number is prime javahow to check if numbers is prime in java inputchecking prime number in javaisprime algorithm javaprime number check javawrite a program to check whether a number is prime or not javawrite a program to find the number of prime numbers in javaget prime numbers javacheck whether a number is prime or not in javaprime number formula javawrite a program to check whether a given number is a prime number or not in javacheck is number is prime javahow to tell if any number is prime javacheck if number is prime or not in javawap to input any number then check whether it special prime no or notreturn if is prime javajava array prime numbersfinding primes in javaprime number checker javaprogram to check prime number in java different wayprime n0 in javajava code checking if a number is a prime numberfunction to check if prime in javajava prime number or notprime no program in javajava prime number algorithmis prime number java best wayprogram to prime number in javaprime no using array in javajava method to determine whet a number is prime or notwrite a program to check if a number is a prime number or not javawhether the number is prime or not in javahow to identify a prime number in javaprime number or 28i 3d2 3b i 3cvalue 3b i 2b 2b 29 7bjava program to check if a nmber is prime or nothow to check the number is prime or not in javawork out prime number in javawrite a program in java to find out if a number is prime in java 3fjava program to check prime or nothow to check the no is pirme or not javajava program to check a number is prime or notjava code checking if a number is primefind prime numbers javajava check if a nymber is primegiven an integer if the number is prime return 1 javachecking for prime number in a range javajava program to find if the given number is a prime numberfunction to check prime number in javacheck given number is prime or not javajava program to find the given number is prime or notcheck number is prime in javaprime number or not program in javamethod to check whether a number is prime java return true if a number is prime using loops javaprime number program in javajava prime number checkerhow to get prime number in javaprime numbe check javajava check prime numberprime number program in java using while loophow to check if numbers are prime in javajava check if number is primehow to calculate a prime number in javaprogram to check whether the given number is prime or not in javagiven number is prime or not in java using if elsehow to figure out prime numbers javamethod that find the prime number of integers javawap to check whether a number is prime or not in javafind prime number by 2 input elements javajava check if prime numberhow to check if integer is primr in javaprime number logic in javahow to check whether a number is prime javaprime number program javabest method to check that number is prime in javahow to find if a number is prime number or not in javacheck for prime javacode to determine if number is prime number or not in javahow to tell if number is prime in javajava program to check whether number is prime or not check int is prime javacheck number is prime java using while loopwap to find whether a number is prime or not in javaa method that checks if an integer is a prime number in javacheck whether n is prime number in javaeasy way to find n prime numbers with array in jvacheck whether a given number is prime or not in javadetermine if a number is prime alhorithm javaprogram to display set of prime numbers using class in javahow to check for prime no in javaprime number in javahow to find the number of primes is a number javajava program for prime numberhow to check primes javaprime number function in javacheck prime in javacheck whether the number is prime or not using do while in javaprime number algorithms javajava check isprimeif a number is prime number or not entered by the user in javapali prime number in javaprogram to find whether the number entered is prime or not in javawrite a java program 2c which will take a number variable and check whether the number is prime or not fastest way to check if number is prime javaa method that checks if an integer is a prome number in javahow to write in java primal numbersjava orime numvertest prime number javato write a java program to read a number from user and check whether it is prime of not java function to check if number is primeprime numbers java algorithmjava program to check whether number is prime or not java test if number is primecommand that verifies if a number is prime javaeasy way to find n prime numbers in jvaprime number algorithm for javawrite a java program to check the number is prime or not check for prime number in javaprime check in javahow to calculate prime no in javafind out if a number is prime in javaalgorithm for checking if a number is prime in javajava number is prime checkjava check if an integer is a prime numberjava prime numberscheck if the entered no is a prime no or not using javahow to test prime number javaprime no program in javacheck whether numbers given are prime javahow to tell if a number is prime using javajava code to find prime numberwrite a java program to check prime number by entering any numberhow to check all prime number in javajava code to check is number is primehow to find prime numbers in java using arrayprime number check in javajava code prime numbercheck dows number prime or no in java using whileis this number prime javajava check number is primecode to check if a number is prime javacheck if the number is a prime number or not in javaprime no logic in javastring function in java to check a number is priem or notjava primary numberfind prime number by 2 elements javafunction to check prime javafinding prime numbers in javaprimary number code javacheck whether prime number or not javacheck prime no in javaprogram to find prime numbers in javaprime number or not check javaprime or not javacheck prime number or not in javacheck if prime or not javahow to check if a prime number is prime javaknow prime number in javaprime logic in javaprint a single integer e2 80 94 the answer to the problem without leading zeroes 2c or 22 1 22 28without the quotes 29 2c if the number that meets the problem condition does not exist prime number code in javahow to check for prime numbers in javachecking a number is prime or not in javaeasiest qy to check if a number is prime in javacheck prime number program in javaprime numbr in javajava program for prime numberswrite a java program to check whether a number is prime or not program to check prime in javawap to check whether a number is prime in javajava check if primeis prime java methodhow to check if prime number in javajava check if a number is prime most efficient solutioncheck if number is not prime javamethod to find if no is prime or not javadetermine prime number javaif number is prime javafind prime numbers from n javaprime number finder javagiven number is prime or not in javaprint prime number java programchaeck if number and opposite is prime in javawrite a program to nuber is prime number or not javahow check prime number in javajava code for finding prime numbershow to see if a number is prime in javaprime numbers condition in javais prime number javacheck if int is primeprogram to check is number is prime or not javacheck is prime number javajava isprime testcompute if its a prime javacheck prime number in java fastest waycheck prime no javahow to check if a int is a prime number in javacheck if prime java 27prime no check in javachecking if number is prime javaprime no or not in javajava for list of prime numbersprime numbers pt rogram using javaava 5cjava program to find prime numberprime numbers program in javajava is prime numberjava program to check whether number is prime or not java if number is primejava how to find if a number is primecheck a number is prime javajava prime or notbest way to check if a number is prime javajava program to check whether a number is prime or not using for loopfastest way to check if a number is prime javawrite a java program to check a number is prime or notjava to print prime numbersjava program to check whether a number is prime or notcheck a prime number in javahow to check if a value is prime in javahow to check if number is prime javajava code to check a prime numberis a number prime javachecking whether a number is prime in javajava how to check if 1 is a primecheck whether the given nos are relatively prime or not in javajava program to check if number is primehow to find primes in javahow to check whether a number is prime or not using javachecking if a given integer is a prime number javacheck number is prime or not javajava code to check if prime numbersjava optomized way to check if number is primeallintitle 3ajava program to check whether number is prime or notprime number test javacheck if num is prime javawap to determine whether an entered number is prime or not in javajava program check if number is prime check whether a given number is a prime or not 7c prime number javajava prime programto to check if number is prime javacheck if a number is prime or not for binary value in javaprime in javacheck if number is prime javacheck no is prime or not javahow to find prime number in java using for loopprime no s in javajava prime number checkhow to find whether a number is prime or not in javacode for prime number in javajava how to check a number is primeee if a number is prime javasearch for prime numbers in array javaprime number java programjav count check if an int is primei th prime number javacheck prime number javamethod to check if integer is prime javaprogram for prime number in javaprogram for checking that nos are relatively prime or not in java3 09write a java program 2c which will take a number variable and check whether the number is prime or not java determine if number is primemaking list of prime numbers javais prime in javajava how to determine if a number is primeprime number or not in javajava program to check whether the number is prime or notjava prime number calculatorjava code to test prime number or notprime number condition in javawrite a program to check if a given number is prime or no javahow to check if number is prime in javaprime no logic in javacheck is prime number in javajava check if int is prime numberprogram to check whether number is prime or not in javacheck if a number is prime or not javacheck if number is prime or not function javajava check number primedetermining if a number is prime javacheck dows number prime or no in javais prime java how to check if an integer is prime in javahow to check prime number javahow to check if a number is prime javaprime numbers javaprogram to check for prime number in javafunction to check if a number is prime in javahow to tell if a number is prime javafind whether a number is prime or not in javatest prime numbers in javasimple prime number finder javaif condition for prime numbers in javahow to find out if a number is prime in javafunction in java to check prime numberjava how to check a set of number is primhow to identify prime number javacheck if a number is prime in javahow to find if a number is k prime in javacreate a class that has a method to find out whether a given number is prime or not 3fcheck for prime numbers in javajav check if an int is primeget primary numbers javalogic to check prime number in javaprime number find in javajava find prime numbershow to test if a number is prime javaprime number code in javawrite a java program to find if the given number is prime or not chech if a number is prime in javajava to check if its a prime nuumber or not scanner methodto check if a number is prime in javaprime no using function in javafind prime number by 2 input integrers javajava program to check prime number using methodscheck if a number is prime javajava code prime number for loopjava program to check whether the number is prime or not gfghow to check if a number is prime in java inputdetermine if prime javaif statement for checking prime numbersin javaprogram to check prime number in javajava find if primehow to check whether a number is prime or not in javafind number is prime or not in javawrite a program to check whether a number is prime or not javahow to check if a number is prime or not in javajava function to find prime numberscheck if prime number javahow to find prime numbers in n in javajava tell if a number is primehow to find prime number in javacode of prime number in javajava program to find primejava program to chekc whether number is primecheck prime number in java gfgto check prime number in javacheck whether the number is prime or not in javahow to know if a number is prime javajava program to find prie numberhow to find the primes of a number javajava how to find if number is primehow to check if a number is a prime number javacheck ifa numberis a prime number in javawrite a program in java to find out if a number is prime in javahow to find prime numbers with javawrite a java program to find prime numberdetermine whether a number is or is not a prime number in javaprimenumber finder javajava code to check prime numberprime checker javacheck number is prime or not in java optiimizedprime check java