prime number

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

showing results for - "prime number"
Anthony
30 Mar 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}}
Valentín
08 Jan 2017
1Numbers -- Prime Number
2Write a method that can check if a number is prime or not
3 
4Solution:
5public static boolean primeNumber(int num) {
6
7    if(num <= 1){
8        return false;
9    }
10
11    for(int i = 2; i < num; i++) {
12        if(num % i == 0) {
13            return false;
14        }
15    }
16
17    return true;
18
19}
Aliya
14 Nov 2020
1def is_prime(n):
2  if(n<0):
3    print("n is not a nature number!")
4    return False
5  for i in range(1,ceil(n/2)+1):
6    if (i != n and i != 1 and n%i == 0):
7      return False
8  return True
9print(is_prime(int(input("number>>"))))
Marie
05 Nov 2019
1a number that is divisible only by itself and 1 (e.g. 2, 3, 5, 7, 11)
2suppose a number 'n' it can be divided by if '1' and only by itself then it can be a prime number
Vincenzo
28 Jan 2018
1// PRIME NUMBER
2// 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.
3
4let number = 5;
5if(number < 2){
6  console.log("less then 2 not prime")
7}
8let flag = false;
9for(let i=2;i<number;i++){
10  if(number % i === 0){
11    flag = true;
12  }
13}
14if(flag){
15  console.log("Not prime ")
16}
17else{
18  console.log("Prime")
19}
20
21
Elisa
06 Mar 2020
1#include<bits/stdc++.h>
2using namespace std;
3bool Is_Prime(long long x){
4	if(x%2==0)return false;
5	for(int i=3;i*i<=x;i+=2)
6		if(x%i==0)return false;
7	return true;
8}
9int main(){
10	long long x;
11	cin>>x;
12	if(Is_Prime(x))cout<<"Is Prime";
13	else cout<<"Is not Prime";
14}
similar questions
prime no
queries leading to this page
how to check if number is prime javaprint prime number code javaprime no or not in javac 2b 2b prime number algorithmprime checker javatest if a number is prime javawrite a program to check if a given number is prime or not what is a prime number in mathhow to print prime numbers in javahow to check all prime number in javahow to check prime number with loop javajava prime number checkeris prime java methodjava program to get prime numbersjava find a prime numbercheck prime no without using functionfind a number relaitively prime with other number javaprime numbers meaningfind prime number in java using while java check fi number is a prime check if prime number javalist of prime number program in javaprime numbers from javahow to check if a number is prime or composite in javawrite a c program to get an integer number from the user and determine if a given number is a prime number or not wap to check prime number using method in javaprime number progra javaprime numbers ischeck prime java while loocheck whether the given nos are relatively prime or not in javajava programe to decide prime numberprime numbers cto identify a prime number javalogic of prime number in javaif a number is prime number or not entered by the user in javawrite a c program to check whether the given number is prime or not given a positive integer n check whether the number is prime or not java program to check prime number input by command line argumentsjava code for prime numberare there even prime numbersfinding the prime number in javais prime number javahow to get prime number in javacheck if the entered no is a prime no or not using javacheck if a number is a prime number javacode for checking prime number in c 2b 2bcheck if number is prime in javanumber of prime numbers c 2b 2bhow to get a prime number in javawrite a java program to find prime numberwrite a java programme to print a number is prime or notprint prime number program in javacheck prime in javawrite a java program to display all prime numberchecking number is prime or not fermatts theorem pyhtonprime no program in java11 write a program to check the prime number in javajava program to find prie numberbest prime number program in javaprogram of prime number in javafunction for checking number is prime or nothow to check whether a number prime numbersjava program for prime numberwhat is int prime number in javaoolean prime in javajava finding prime numberscheck whether prime number java programprogramming with java prime prime logic javahow to check given number is prime or not in javaisprime function inc cprogram to print prime numberswrite a program to check if a given number is prime or not in javanumber of prime or not program in javaprime number of anumber in javaprime number checker javaprogram to find prime numbers javaprime number exmaple in javaprime number coding logicprime numbers programs in javaprime numbers using javahow is prime number method in javahow to find prime numbers javaall pali prime number in javahow to find prime number javaprime number formula javacheck whether prime or notwrite a java program to check a number is prime or notprime number or not program in javaprime no program in java user inputhow to find number of prime numbers up to to n javaprime number calculator javacheck prime and print prime in javaprimes numbersto find a number is prime or nothow to find a prime number in javapriem method in javaprogram for prime no in javaa prime number in javafind prime number in java using for loopis there a class in java with prime numbersdetect prime numberjava how to get prime or compositevalidate if a number is prime cprime or not in cppwork out prime number in javaho to find the amount of prime number in javaprime number logicfind prime number in java avapointhow to identify prime number javaprime javaprime no functionwap in c to find prime numbersprime number in javacheck if a number is prime or not for binary value in javaprime number in java gfg practicecheck if a number is prime or not javascratch code check if number is primefind if the number is a prime number in ccpp efficient program to find if a number is prime or otgjava primeprime number utility i javafind prime number in java 8find prime number program in javahow do i calculate prime number using javajava prime numbersn prime number or not in javac check for prime numberwrite a program to find a given number is prime number or not javajava code to check for a prime numberget prime numbers javaprint prime numbers in javajava program to check prime number using methodsjava program to check given number is prime or notprime numbers algorithm in javaprogram to find a prime number in javawhats is prime numbershow to check if a number is prime in java inputhow to find whethe a number is prime or notwrite a program to check the prime number in javacheck prime numberprime numberssimplest prime number check cjava code to find prime numberjava prime number usingprime no logic in javais prime method java which classjava find prime numbershow to write in java prime numbersall prime numbers in javaprint prime number in javawrite a java program 2c which will take a number variable and check whether the number is prime or not function to check if number is primejava program to determine prime numberprime number in javaprime number logic in cis composite the opposite of prime numberprime numbr in javajava program to check prime numberhow to find prime number in javahow to find prime numbers programm in javaprime number program in java using functionlist of prime numberscheck number is prime or not in c program3 write a program that prompts the user to input a positive integer it should then output a message indicating whether the number is a prime number examples of prime numbers are 3a 2 2c 3 2c 5 2c 7 2c 11 2c 15 2c 17 prime no in javaprime number function javaall prime numberscheck prime number ccode for prime no in javais prime number in java optimaljava prime number programwrite a java program to check prime number by entering any numberhow to check for prime number in javaprimes number javasimple prime number logic in javahow to find out if a number is prime in javaprime numbers program in javanumber primeshow to write a prime number program in javaprime numbers programmingjava code to check prime numberhow to find number of prime numbers using javafinding prime numbers for given number in javais prime numer javahow to find if number is prim javacheck for prime numbers javahow to write prime number by using method and function in javacheck prime number in java using for loopjava find prime numbers funktionc program to find whther inputed number is prime or notjava get write prime numbersjava program to check prime number or notjava get primesjava check for prime numberprime detecting javahow to determine prime numbers in javaprime number java programgetting a set of prime numbers javaprime number loop javacheck for prime javafind prime number by 2 elements javaisprime function in cshow is prime number method in javacode for prime number javaprime no in javaprime no s in javatesting for prime number in javajava program to find prime number using methodcheck prime cfinding prime number javac 2b 2b program for prime numberhow to print a prime number in javac prog prime numberprogram to find prime numberprime number formula c 2b 2bjava code to find prime numbersto check prime number in javawhat are prime numbersprime number code in javahow to check for a prime number in javajava fastest way to get prime numberscheck if prime c 2b 2bnumber is prime or nothow to find whether a number is prime or notjava program to find prime numberhow to find a prime javafind prime number using javaprime number program in java programizcondition for prime num 2cbersprime numbers method javachecking prime number in javajava program to find a number is prime or notprime number logic javac program to check whether a number is prime or not without loopprime no logic in cfind whether number is prime or notjava program to find a prime numberbest way to find prime numbers in javahow to check for prime numbers javafind prime number javaprime no in javasimple java program for prime numberjava program to prime numberjava isprime testhow to code a program that displays prime numbers in javawrite a java program to check whether the number is prime or notwhether number is prime or notprime number program in javadisplay prime number javaprime number finding in javaprime numbers codefind prime number in javaprogram to find prime number in javaprime number program javaprime number testing in javacalculate the t prime number program in javaprime numbers java programfinding prime number javahow to prime numbers in javahow to find prime in javaall prime numbers javajava program to check whether number is prime or notjava program on prime numberprogram to find nuber is prime or nithow to find prime and nonprime numbers in javawrite a java program to check whether given number is prime or not write a java program to check if a given number is prime or notlogic for prime number in javaprime number in codeprime numberprogram to check prime number in javajava code for prime number checking from userhow to determine a prime number in javajava if number is primeprime no code in javacheck whether a number is prime or not without loopc 2b 2b code prime numbersimplest prime number program javaprime number using javaprime number definitionhow to find the prime number in javajava prime packagecheck for prime number in javaprime and composite numbers java codecheck number is prime or not in java optiimizedhow to check if number prime in javajava how to find prime numberscheck for prime numbers in javais a number prime javafunction prime number logic in javajava code prime numberdoes java a built in prime number methodhow to check prime no in javaprime numbers java functionwhat is prime number javaprime number in java user inputjava find prime numbers fromwhat is the prime numbersjava code to calculate prime numberprime cpphow to check prime numbers in javaprime prime numberswrite a program to print prime numbers in javafind prime no code in javahow to calculate prime number javahow to identify a prime numbernumber is prime or not program javawrite a program to print prime number in javajava code to check is number is primeprimary number code javafind if a number is primewrite a java program to find whether a number is primeprim number javawhat are prime numbers 3fjava program to check whether a number is prime or notcondition for prime numberswrite a program in java to find out if a number is prime in javahow to check prime or not in java prime numbers javacheck is prime javaprime numbers formula in javac 2b 2b prime numberscondition for prime numberprime number math program javahow to check prime number in c 2b 2bcode for prime number in javato find prime number in java in set of elementsprime nuber in javahow to check prime number in cpphow to check for prime numbers in javafind a prime number javaprime numbers javajava code to get prime numbersfind primes in javaprime number program in java using scannerprogram to find prime in javafind prime number in java methodprime nmber in javaa number is prime or not in javafind prime number by 2 input integrers javajava method for prime numbersfind prime numbers javacalculate prime numbers javaprint prime number javaprime no logic c code to find prime numberhighest prime number code in javahow to write code for prime numbers in javawhat is a prime no javahow to find prime numbers using javaprime number program in java using for loopc program to test prime numberloop 26 if structure to test whether an input number is prime or composite what is the logic of prime number in javajava program finding prime numbersprime number program in java using user inputjava program to find the given number is prime or notyou are given one number n you must write a program to test whether the given number is prime or not note 3a a prime number is such a number that has only two factors 3a i e 1 and itself 1 is not a prime number prime number code in jvaaprime number finder javaprime number function in javaprime number c 2b 2bjava print prime numbersprime numbers below a given number javajava prime or compositefind prime numbermethod to get prime numbers in javabest way to print prime numbers in javahow to check for prime in javajava program prime numberprime numbers code in javajava check if a number is primeprime number or not javadetermine prime numbers javaprogram to check prime numberis prime in java checking whether a number is prime or not in cjava prime number checkcheck if a number is prime javajava program to get prime numbers or notlogic for primesfind the prime number java codefind whether a number is prime or notfinding prime number in c 2b 2bprint prime numbers testprint prime numbers up to a given number in javajava how to check if a number is a prime numberhow to check prime number javaprime numbers function in javais prime c 2b 2bc program to print prime numbershow to find prime numbers with help of and operator in javaprime number in java using 2fgenerate prime numbers javaprime method in javaprogram to find prime numbers in chow to solve prime numbers javaprime not prime in javaprinting prime numbers in javahow to find prime number series in javahow to check if numbers is prime in java inputjava program to check whether the number is prime or notfind if a number is prime or notprime numbers in java gfgprime integer javaprime or not javacode to determine if number is prime number or not in javahow to check if number is prime in cfind prime no in javajava program to find primeprime no javafind prime number or not in javawhat is the login for prime numbers to write in javafind whether a number is prime or not in javaprime finder javahow to find the number of primes is a number javahow to find prime and composite numbers in javaprime or not in javaprime number java 8prime number check codepimenumber javaprogram to prime number in javajava program for prime numbersjava code program prime numbersprogram to count prime numbers in javac math is primehow to prime number in javafind prime number in c 2b 2bprogram to find the prime number in a given range javafunctions that find prime numberprime numbers condition in javacalculating prime numbers javaprogram to check prime number in java different wayprogram to check for prime number in javaprint prime numbers from given number in javaprime number logic in javajava program prime numberscheck prime cppfind prime numbers from n javaconditions to check prime number using squarefind prime number by 2 input elements javaprime no logic in javaprime number java logicsquare numbers and prime numbers javawhat are the prime numbersprogram to find if a number is primewrite a java program to determine whether a number is or is not a prime numberjava prime numbercalculate prime number in java using functionprime number javahow to find prime numbers c 2b 2bjava program to check prime number using for loopidentify a prime number javafinding prime numbers in javajava is 0 prime numberprime built in function in javac how to chek if primejava prime number allis prime function javaquick math to determine prime numbercheck if numbe is prime c 2b 2bprime number in least time in javawhat is prime numbersjava prime number with for loophow to check if a number is prime or composite in cprime of primes program in javaprime number code javajava is prime functionhow to find primes in javahow to tell if a number is primefind prime numbers c 2b 2bcheck prime number in javais prime javaprime logic in javaisprime how to check for prime numbers c 2b 2bfunction to check whether a number is prime or notcondition for prime number in javahow to find prie in javawrite a java program to check prime numberhow to find prime numbers in javahow to check if a number is prime in javaprime number in java printjava calculate prime numberjava is prime numberhow to find prime numbers with javahow prime number in javafind prime number or nothow to get prime nu 2cbers javajava prime number functionhow to find that the number is prime or notvarious logic for checking prime numberprime numbers def javawhich number is prime numberjava program to check whether a number is prime or compositeprimenumbers javacheck if number is prime javahow do u know if a number is a prime in programming c c code for prime numbersfinding prime number in javahow to calculate prime number in javaprime number coding in javawrite a program to find out if a number is primejava find prime numberprime num javaread an array of integers in your overloaded main method and determine how many numbers are prime numbers and composite numbers get prime number in javawhat is prime number in javaprime number identifier java functionprogram to know if a number is primefind prime in javaprime number or not in javaprime or not in java in javac 2b 2b 28prime numbers 29 an integer is said to be prime if it e2 80 99s divisible by only 1 and itself for example 2c 2 2c 3 2c 5 and 7 are prime 2c but 4 2c 6 2c 8 and 9 are not write a function that determines whether a given number is prime prime code in javahow to check the no is prime or not in javaprime check c 2b 2bhow to find if a number is prime in javaprime numbers definitioncheck prime number using cprogram to find prime numbers in javaprime numbers listprime number print in javahow to solve for prime number javaprogram to check for prime numbers in javafind prime numbers in javajava integer prime numberprogram prime number in javahow to find if a number is primehow to check if a number is a prime in java in 1 linejava prime number prime checker program javahow to check if a number is prime in cppwrite a program in java to find out if a number is prime in java 3fprime numbers in javanon prime number java program to check if a number is prime javajava how to check if a number is primeprime in javacount of prime numbers java programfunction to find prime number javagiven number is prime or not in javaprime number check in javahow to find the prime numbers in java methoddetermining if a number is prime javajava find prime number methodprime number find in javacheck whether number is prime or notnumber prime or not in javaprime number check javahow to find prime number c 2b 2bc 2b 2b program prime numberjava code for prime number checkingprime number in java shortest codefinding prime numbers c 2b 2bjava code to finde prime numberprime number java codec 2b 2b check ir prime numberfind if number is prime javaprint n prime number in javaprime number algorithm javahow to check whether a number is prime or not in javainput a positive integer it should then output a message indicating whether the number is a prime number example 3a enter a number 3a 31 31 is a prime numberlist of all prime numberswhat are prime numbers in javajava prime number using whillefind all prime numbers javac 2b 2b check prime or notcheck for prime number javajava program to print highest prime numbercalculate prime number in javalist of primenumbershow to calculate prime numbets in javacode for prime numbers javajava coding to find prime numberprime numbersjava to check if its a prime nuumber or not scanner methodwrite a program to find whether the given number is prime or notcalculate check prime number in java using functioncheck if number is prime in cif its a prime number javawap to find prime number in javajava program to print prime numberscode to find prime number in javaprime number java program simpletest my code for prime numberssimple prime number program in javawrite a program to check whether a given number is a prime number or not in javahow to find the number is prime or not javaprime logic in javahow to find prime in programmingcheck prime number javaprime number condition javaisprime c 2b 2bnumber is prime or not in javajava prime or notprime numbers c 2b 2boptimal way to check wheter given number is prime or not in javahow to check prime number in javajava is number a prime numberprogram to find prime numbersprime numbers formula javaprime number in java programmizjava code for prime number or nptologic for prime numbersprime number codelogic to find prime number prime in javaprint prime number using javajava find all prime numbershow to add prime numbers in javaprime number icode in javajava all prime numberhow to write algorithm of a prime number determining programme in cexplain prime number logic in javacheck prime javacode find prime numbersprime and non prime javadefine prime numbersprime no logicfind if a number is prime javacheck number is prime or not in javaprint number of prime number user value in javajava rmi prime number programprint only prime numbers in javahow many ways to create prime number in javawrite a java program for prime numberhow to find a number is prime or not in javajava program to find prime numberswrite a program to check if a number is a prime number or not javaa program to check if a number is prime javat prime in javacheck prime c 2b 2b 2a prime numbersjava to find prime numberprogram for prime number in javacheck prime number in cprime detecting java from 1 to nhow to determine if a number is prime in javaprime nujmber in javajava print all prime numbers that can be made form a numberprime number