prime in java

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

showing results for - "prime in java"
Mina
27 Jun 2019
1public class Prime {
2    public static void main(String[] args) {
3
4        int num = 29;
5        boolean flag = false;
6        for(int i = 2; i <= num/2; ++i){
7            if(num % i == 0){
8                flag = true;
9                break;
10            }
11        }
12
13        if (!flag)
14            System.out.println(num + " is a prime number.");
15        else
16            System.out.println(num + " is not a prime number.");
17}}
Jacopo
12 Sep 2016
1public class Prime {
2    public static void main(String[] args) {
3
4        int num = 29;
5        boolean flag = false;
6        for(int i = 2; i <= num/2; ++i){
7            if(num % i == 0){
8                flag = true;
9                break;
10            }
11        }
12
13        if (!flag)
14            System.out.println(num + " is a prime number.");
15        else
16            System.out.println(num + " is not a prime number.");
17}}
18Source:www.progra
19
Michele
20 Sep 2016
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}
Luna
25 Jan 2020
1public class Prime {
2   public static boolean isPrime(int num) {
3        if (num<2)
4            return false;
5        for(int i=3;i<=Math.sqrt(num);i+=2)
6            if(num%i==0)
7        return  false ;
8        return true ;
9    }
10}
queries leading to this page
java program for prime numberwrite a program to check whether a number is prime or not javahow to check number is prime or not in javahow to get prime number in javacode to determine if number is prime number or not in javahow to get big prime number in javacheck if the number is a prime number or not in javajava rmi prime number programhow to find if a number is prime number or not in javajava prime or compositejava prime nujava check isprimeto identify a prime number javaprime logic in javawrite a java program to check if a given number is prime or notwap to check whether a number is prime or not in javacheck if num is prime javahow to check for a prime number in javahow to check prime in string javacheck if number is prime or not function javahow to check if prime number in javahow to find prime numbers in n in javajava code to check the the number is prime numberif a number is prime number or not entered by the user in javais prime javahow to print prime number series in javajava program to check whether a number is prime or notlogic for prime number in javahow prime number in javahow to find the primes of a number javajava code prime number for loopis prime number in java optimalhow to check if number prime in javajava program to find the given number is prime or notlogic to check prime number in javahow to make print a prime numbers in javajava program check if number is prime best prime number program in javajava to print prime numberscheck for prime javawhat are prime numbersis prime method javajava code to find prime numbers to check if a number is prime javaprogram for prime no in javacheck whether a given number is a prime or not 7c prime number javacheck for prime number in javawap to find prime number in javahow many ways to create prime number in javahow to find prime numbers with help of and operator in javaprime numbers in java gfgprime inbuilt function in javachecking prime number in javacheck a number is prime in javaprogram to check prime in javamethod to check if integer is prime javasimple prime number logic in javahow to check if a value is prime in javajava is primeprint prime number code javahow to find whether a number is prime or not in javahow to calculate prime number javacheck whether a given number is prime or not in javajava method for prime numbersidentify a prime number javajava check if a nymber is primefind a prime number javaprint number of prime number user value in javawhat is the login for prime numbers to write in javahow to check if a number is prime or not in javajava orime numverprogram to find the prime number in a given range javais a number prime javajava find prime number methodprime numbers program in javaeasy way to find n prime numbers with array in jvaprinting prime numbers in javajava how to get prime or compositejava prime number or notgiven number is prime or not in javahow to tell if a number is prime using javaprime no using function in javawrite a java program to determine whether a number is or is not a prime numberhow to tell if number is prime in javaprime checker program javacode to check if a number is prime in javaprime no s in javaprime number in java gfg practicecheck number is prime in javahighest prime number code in javacheck for prime numbers javaprime check javachecking a number is prime or not in javajava to check if its a prime nuumber or notcheck if int is primehow to check whether a number is prime or not in javajava how to check if a number is a prime numberprime no or not in javabest method to check that number is prime in javaprime number in java programmizprime number loop javaprogram to check is number is prime or not javanumber of prime or not program in javachaeck if number and opposite is prime in javaprime number program in java using for loopprime number condition javajava check if an integer is a prime number recursiveprime in javais prime function in javaprime number function in javajava is prime numbercalculate check prime number in java using functionexplain prime number logic in javajava is prime o 281 29how to write in java primal numberscode for prime no in javajava function to find prime numberscheck prime and print prime in javahow to check if a int is a prime number in javaefficient way to find prime numbers in javahow to find a number is prime or not in javahow to check if a number is a prime in java in 1 lineprime no code in javajava check if primecommand that verifies if a number is prime javacan void check if a number is prime in java search for prime numbers in array javaprint prime numbers up to a given number in javaprogram prime number in javafinding prime number in javajava program to check whether the number is prime or nothow to check the number is prime or not in javahow to find is a number is prime in javajava program to get prime numbersjava program to find prime number using methodjava program to see if a number is prime numberprime number identifier java functionjava to check if its a prime nuumber or not scanner methodprime numbers java functionprime number or 28i 3d2 3b i 3cvalue 3b i 2b 2b 29 7bis prime in javahow to check if numbers is prime in java inputcheck if prime number javaprime function in javahow to create primes in javahow to check the no is pirme or not javajava code to calculate prime numberhow to checl if a number is prime javaprime finder javajava check if int is prime numberjava program on prime numberalgorithm for prime number in javabest way to find prime numbers in javatesting for prime number in javadefine prime numberswrite a program to check if a given number is prime or not in javahow to find whether the number is prime or composite in javato check prime number in javacheck dows number prime or no in javahow to find prime numbers using javajava is 0 prime numberprogram for prime number in javajava program to check whether a number is prime or compositehow to find prime numbers in java using arrayfind prime number javacheck number is prime javahow to find primes in javajava get write prime numbershow to prime numbers in javahow to check all prime number in javajava code to check prime numberjava prime number checkerprime number condition in javaprime numbers definitionhow to determine prime numbers in javahow to find prime in javahow to write prime number by using method and function in javaprime number program in java using functionjava prime programjava program to display prime numbersjava prime number usingjava code to check a number is primejava prime packageprime number testing in javajava program to print prime number seriesprimes javajava prime number calculatorprime logic javafind prime number by 2 elements javacount of prime numbers java programdetermine if a number is prime algorithm javawrite a program to nuber is prime number or not javafind if a number is prime or not in javajava for list of prime numbersprime number finding in javajava program to find a number is prime or notprint 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 javachecking for prime number in a range javajava program to find whether a number is prime or notcalculate prime numbers javafind prime no in javawap to check prime number using method in javacheck whether a no is prime or not in javajava program to print highest prime numberdetermine prime number javaprime built in function in javaprime and non prime javaprime number in java printjava program to check prime number input by command line argumentshow to calculate prime number in javaall pali prime number in javahow is prime number method in javaprimes number javawrite a program to check if a given number is prime or no javawap to find whether a number is prime or not in javaprint prime numbers in javajava program to check whether number is prime or not prime number logic javaprime numbers pt rogram using javaava 5cjava prime numberfind prime no code in javaprime number or not javacode java prime numberbest java program to find prime number or notcheck whether prime number java programhow to calculate a prime number in javafind prime in javan prime number or not in javaprime number algorithm in javaif statement for checking prime numbersin javawrite a program to find out if a number is prime javajava determine if number is primefastest way to calculate prime or not in javaprime no in javaprime number coding in javahow to check if prime number javaprogram to find prime numbers javadetermine whether a number is or is not a prime number in javacheck for prime number javacheck a prime number in javawrite a java program to display all prime numberhow to determine if a number is prime in javaprimes numbersprime number algorithm for javanumbers primeprime numbers java programsimplest prime number program javaprogram to find prime numbers in javacheck prime no javaa prime number in javajava to find prime numberfinding prime numbers for given number in javajava find if a number is primeprime number definitioncheck prime number in java using for loopchecking if a number is prime javafind out if a number is prime in javawrite a java program for prime numbertest for prime number javagood algo to find prime number in javacan java tell if a number is primeprime no logic in javahow to see if a number is prime in javahow to check whether a number is prime or not using javawrite a java program to print prime numbersknow prime number in javajava code for prime number or npthow to test if a number is prime javahow to determine a prime number in javajava prime number allmethod to get prime numbers in javamethod to generate prime number in javaprogram to find a prime number in javaprime number algorithm javahow to check if number is prime javajava primary numberprime number or not in javahow to identify a prime number in javalist of prime number program in javaee if a number is prime javaprime no program in java user inputhow to check for prime numbers javacheck whether numbers are prime javafinding prime number javawhat is prime number javahow to find prime numbers with javaprime number print in javacode for prime number javaprime numbers code in javajava program to determine if a number is primeprime code in javaprime nujmber in javajava prime number functionprint prime number using javacheck a number is prime javaprime function javacheck a number is prime or not in javahow to check for prime number in javajava program to check prime number or notprime numbers below a given number javaprime number find in javahow to check if a number is a prime in java in o 281 29i th prime number java11 write a program to check the prime number in javaprint n prime number in javatest if a number is prime javahow to find out if a number is prime in javahow to find prime numbers javacheck if a number is prime in javajava prime number get prime numbers javasimple java program for prime numberprint prime number program in javaprime number using javawrite a java program to find prime numberbest way to print prime numbers in javaprime number in java shortest codejava check if an integer is a prime numberprime number program in java using scannerjava integer prime numberwrite a java program to check whether the number is prime or notprimary number code javaprogram to check for prime numbers in javajava prime checkjava program for prime numbersprogram to count prime numbers in javahow to check if number prime in javafastest way to check if a number is prime javaprime number formula javajava program to find prime numberisprime method javaall prime numbers in javaprime numbers formula in javajava prime number using whillehow to print prime numbers in javahow to determine if number is prime javajava code for prime number checkingfind the prime number for given array in javahow to tell if a number is prime javaprime number algorithms javawhy 4 is prime number in javajavacheck prime numbercheck number is prime or not in java optiimizedhow to find prime and composite numbers in javajava program to check if a number is primehow to check prime number in javaprime number check javaprime check in javawhat is a prime no javajava program to check whether number is prime or not prime detecting javawhat is int prime number in javaprime check function in javafind if number is prime javacheck whether the given nos are relatively prime or not in javaalgorithm to find prime number for series in javajava code to check for a prime numberwrite a program to print prime number in javamath prime javajava oop prime finderjava prime nofind prime numbers from n javato find prime number in java in set of elementsall prime numbers javahow to find prime number in javafind prime number in java using while check given number is prime or not javafind the prime number java codejava program prime numberhow to check prime numbers in javahow to get a prime number in javajava check if a number is primehow to check if an integer is prime in javais prime method java which classhow to check if a number is prime in javaprime numbers def javajava check for prime numberho to find the amount of prime number in javahow to find the number is prime or not javafind prime number by 2 input elements javajava test if number is primehow to find prime number javapal prime number program in java gfgprime genrator javaprimeng javajava prime or nothow to check if a number is prime javaprimenumber java programmeprime number in javaprogram to check whether number is prime or not in javaprint prime javacheck prime in javasquare numbers and prime numbers javaprogram to find prime number in javajava method to determine whet a number is prime or notgiven number is prime or not in java using if elseis prime numer javafind a number relaitively prime with other number javahow to check if number is prime in javafind prime number in java 8check whether a number is prime or not in javachecking whether a number is prime in javaprime number or not program in javajava how to check if a number is primejava number is prime checkhow to determine if a number is prime javaprime numbers java for loopdetermining if a number is prime javajava program to check if number is primehow to find a prime javahow check prime number in javajava optomized way to check if number is primeis this number prime javaprime or not javahow to check if integer is primr in javajava program to get prime numbers or nothow to check prime number javaprim number javajava program to find prime numbersjava program to check whether number is prime or not prime of primes program in javajava all prime numberwrite a java program to check prime number by entering any numberfinding prime numbers in javacheck whether the number is prime or not in javaprimary number in javacode of prime number in javaprime method in javaprime numbr in javawrite a java program 2c which will take a number variable and check whether the number is prime or not prime operator javawrite a program to check whether a given number is a prime number or not in javajava program to check given number is prime or notfind whether a number is prime or not in javajava find all prime numbersprime number progra javaprime nuber in javajava code checking if a number is primefind prime number or not in javajava programe to decide prime numberidentify prime in javawhat is prime numbersprime numbers algorithm in javacheck if a number is prime or not for binary value in javachecking if number is prime javaprime number program javacheck if a number is prime or not javacalculating prime numbers javato check if a number is prime in javaprime numbers explainedwrite a program to print prime numbers in javajava program to prime numberhow to write in java prime numbersis there a class in java with prime numbershow to find prime number in array javawhat does primes 2b 3d mean in javajava program to check prime numberjava code to find prime numberfinding prime number javajava program to check whether number is prime or not how to find number of prime numbers up to to n javaprime number math program javaprime javaprint prime number in javaprime numbers till the number in javajava code for finding prime numbersjava program to find primegetting a set of prime numbers javaprime or not in javawrite a java program to find whether a number is primecheck ifa numberis a prime number in javaprime number utility i javaprint prime no in javaprogram to prime number in javawrite a program to check the prime number in javacheck whether number is prime or not javajava how to check a number is primejava program finding prime numbersprime number exmaple in javajava code to get prime numbersjava array prime numbershow to check given number is prime or not in javajava prime number checkcheck int is prime javajava code program prime numbersjava program to check prime number using for looptest prime number javacheck prime number in java fastest waya number is prime or not in javafind if a number is prime javaprogram to check for prime number in javafind prime number by 2 input integrers javaprime numbers in javaprime detecting java from 1 to njava primejava check if prime numberprogram of prime number in javajava program to check whether a number is prime or not using for loop forchecking if a given integer is a prime number javacheck whether the number is prime or not using do while in javaprimenumber finder javahow to check if number prime in javawrite a java program to check number is prime or notjava how to find if a number is primehow to check if a number is prime java for loopfind prime number program in javajav count check if an int is primepimenumber javanext prime number javaprime number in java user inputprime number of anumber in javajava check prime numberprime num javaprime no using array in javacalculate prime number in javawhether the number is prime or not in javanumber is prime or not program javaget primary numbers javawriting a prime function javacheck if a number is prime java programprime number code in jvaalogic of prime number in javahow to check for prime in javaprime number program in javaprime number javajava program to determine if primework out prime number in javaprime number in least time in javamethod to check whether a number is prime java if number is prime javajava prime numbersprime numbers function in javaprime numbe check javaprime no logic in javajava program to check prime number using methodsjava program to find a prime numbergiven an integer if the number is prime return 1 javaprime numbers javashow is prime number method in javajava coding to find prime numberwhat is prime number in java prime in javaprogram to check prime number in java different waycheck for prime numbers in javaprime checker javahow to calculate prime numbets in javahow to find number of prime numbers using javajava if number is primecheck is prime number javaprime method javadetermine prime numbers java prime numbers javareturn if is prime javahow to check if a number is prime in java inputdetetc prime number javaa method that checks if an integer is a prime number in javahow to check for prime no in javaprime not prime in javawrite a program to check if a given number is prime or not show left side no prime in javawrite a program to find a given number is prime number or not javaprime number 29easiest qy to check if a number is prime in javaprime nmber in javacheck prime no in javajava program to find if the given number is a prime numbermethod that find the prime number of integers javawap to input any number then check whether it special prime no or notget prime number in javasimple prime number program in javajava primeprint prime number java programjava prime number programhow to solve prime numbers javahow to identify prime number javaprime integer javajava how to determine if a number is primefastest way to check if number is prime javacheck prime number or not in javafind all prime numbers javato to check if number is prime javafunction to find prime number javahow to find the prime numbers in java methodhow to find prime and nonprime numbers in javaprogram for checking that nos are relatively prime or not in javacalculate the t prime number program in javahow to check for prime numbers in javahow to code a program that displays prime numbers in javaprime logic in javacheck is prime javacheck if the entered no is a prime no or not using javawrite a program in java to find out if a number is prime in javaprime no program in javajava program to check whether number is prime or notprogram to find prime in javaprime numbers from javafind prime numver in javaprime number java program simplecheck whether number is prime or not in javacheck if number is prime or not javacheck whether prime number or not javanumber is prime or not in javawap to print prime number in javaprime no javajava program prime numberscheck if number is prime or not in javaread an array of integers in your overloaded main method and determine how many numbers are prime numbers and composite numbers program to display set of prime numbers using class in javacalculate prime numbers in javajava code to check a prime numbercheck if it 27s a prime number javafind primes in javacode for prime number in javahow to check prime no in javacheck prime number in javais prime method in javajava program to find prie numberwrite a program in java to find out if a number is prime in java 3fwrite a java program to check prime numberhow do i calculate prime number using javais prime number java best wayprogram to check whether the given number is prime or not in javajava find a prime numberprime no in javahow to write code for prime numbers in javacheck if the number is prime javagenerate prime numbers javaprime number in java using 2fhow to find the prime number in javafind prime number in javajava prime number with for loopcondition for prime number in javacheck is number is prime javajava find prime numbers funktionjava isprime testprime numbers meaningcreate a class that has a method to find out whether a given number is prime or not 3fjava program to check a number is prime or notoptimal way to check wheter given number is prime or not in javajava find prime numbers fromprime n0 in javawhat is the logic of prime number in javastring function in java to check a number is priem or nothow to check prime or not in javajava program to find prime numbers in an arraymaking list of prime numbers javahow to find a prime number in javaprime number checker javacheck if prime javaprim function javadisplay prime number javahow to check if number is pime javapali prime number in javacheck prime java while loowrite a java program to check the number is prime or not check whether numbers given are prime javajava check fi number is a prime how to check if a number is a prime number javaprime number java codeoolean prime in javajava is number a prime numberprime numbers formula javajava tell if a number is primejava code checking if a number is a prime numberprogramming with java prime input any number to check prime in javajava code for prime numberprime and composite numbers java codewrite a java program to check whether given number is prime or not check if number is prime javajava program to find prime number or notcheck prime number javahow to find the number of primes is a number javaprogram to check prime number in javaprime number calculator javajava best way to determine if number is primeprime number function javajava program to see if number is prime or notprime number code javaprime numbers condition in javaprime number check in javaprime number icode in javahow to check a number is prime or not in javajava program to check if a nmber is prime or notprime number funtion javawrite a program to check whether a number is prime or not javahow to know if a number is prime javaprime number java logicfunction prime number logic in javajava function to check if number is primehow to check prime number with loop javahow to check if a number is prime or composite in javahow to check whether a number is prime javaalgorithm for checking if a number is prime in javaprime number test javawrite a java programme to print a number is prime or notreturn true if a number is prime using loops javahow to check number is prime javahow to check the no is prime or not in javahow to check if numbers are prime in javaprime numbers method javaprime number java 8prime i javajava how to find prime numbersis prime in java functionfind prime numbers in javahow to find prime numbers in javaa method that checks if an integer is a prome number in javaprogram to find whether the number entered is prime or not in javawrite a java program to check whether a number is prime or not java code for prime number checking from usercheck if the int is a prime number in javaprime no in javaprime numbersnumber prime or not in javafind if the number is prime number java the stupid wayprime number finder javaprime or not in java in javaif its a prime number javaprime number in javafind prime number using javawrite a program to check if a number is a prime number or not javaprime no javajava calculate prime numberis prime function javahow to add prime numbers in javacheck given number is prime or not in javadetermine if a number is prime alhorithm javachech if a number is prime in javajava finding prime numbersisprime algorithm javaprint only prime numbers in javacheck if a number is prime javacheck if number is prime in javahow to calculate prime no in javacheck number is prime or not javahow to test if a number is prime in javaeasy way to find n prime numbers in jvahow to figure out prime numbers javafind prime number in java avapointhow to solve for prime number javawrite a java program to find if the given number is prime or not function in java to check prime numberjav check if an int is primehow to find primes javajava fastest way to get prime numbersjava method to check for prime numbers3 09write a java program 2c which will take a number variable and check whether the number is prime or not how to find if a number is k prime in javafind prime numbers javadoes java a built in prime number methodwhat are prime numbers in javacheck no is prime or not javawap to check whether a number is prime in javahow to check if 1 is prime javaprime numbers detection program in javat prime in javawhat are the prime numbersnon prime number java programhow to find prime number series in javajava find if primefind prime number in java using for loopprime number or not check javafind prime number in java methodprime numbers using javajava how to check if 1 is a primeprime java rocresiacheck whether n is prime number in javacode for prime numbers javafinding the prime number java how to write a prime number program in javaprime number program in java using user inputwrite a function to check whether a number is prime or not in javahow to print a number and see if it is prime or not in javahow to find prime numbers programm in javahow to get prime number in javajava check if number is prime1 you 27ve to check whether a given number is prime or not javajava code to check if prime numbersjava program to know if given number is primehow to find prie in javaprint prime numbers from given number in javahow to get prime nu 2cbers javajava code to finde prime numbera program to check if a number is prime javawrite a program to find the number of prime numbers in javajava program to determine prime numberprime numbers isprime number logic in javajava how to find if number is primehow to tell if any number is prime javawrite a java program to check a number is prime or notpriem method in javajava find prime numberscode to find prime number in javaprint prime number javajava code prime numbercheck number is prime or not in javanumber is prime or not javacheck if number is not prime javajava is prime functionprimenumbers javahow to prime number in javajava print prime numbersfind number is prime or not in javacheck if a number is a prime number javaprime number program in java programizcalculate prime number in java using functionprime number program in java using while loopfind the given number is prime or not in javafinding the prime number in javajava get primeswrite a program to check if given number is prime number in javaprime numbers programs in javacheck prime javajava program to check whether a number is prime or not using for loopcode to check if a number is prime javaprime number code in javahow to print a prime number in javahow to find if number is prim javajava program check if number is prime forfunction to check if a number is prime in javajava print all prime numbers that can be made form a numberwrite a program to check if a given number is prime or not java find prime numberis prime java methodprime number java programis prime number javafunction to check if a number is primein javajava program to print prime numbersjava check if a number is prime most efficient solutionjava program to check whether the number is prime or not gfghow to find if a number is prime in javaprime in java