java program to display prime numbers from 1 to 100

Solutions on MaxInterview for java program to display prime numbers from 1 to 100 by the best coders in the world

showing results for - "java program to display prime numbers from 1 to 100"
Jonathan
21 Aug 2018
1public class Main {
2  public static void main(String[] args) {
3    for (int i = 2; i < 100; ++i) {
4      boolean isPrime = true;
5      int sqrt = (int)Math.ceil(Math.sqrt(i));
6      for (int divisor = 2; divisor <= sqrt; ++divisor) {
7        if (i % divisor == 0) {
8          isPrime = false;
9          break;
10        }
11      }
12      if (isPrime) {
13        System.out.println(i);
14      }
15    }
16  }
17}
Kamil
31 Jun 2019
1class PrimeNumbers
2{
3   public static void main (String[] args)
4   {		
5       int i =0;
6       int num =0;
7       //Empty String
8       String  primeNumbers = "";
9
10       for (i = 1; i <= 100; i++)         
11       { 		  	  
12          int counter=0; 	  
13          for(num =i; num>=1; num--)
14	  {
15             if(i%num==0)
16	     {
17 		counter = counter + 1;
18	     }
19	  }
20	  if (counter ==2)
21	  {
22	     //Appended the Prime number to the String
23	     primeNumbers = primeNumbers + i + " ";
24	  }	
25       }	
26       System.out.println("Prime numbers from 1 to 100 are :");
27       System.out.println(primeNumbers);
28   }
29}
Gregg
24 Aug 2020
1public class PrimeNumbersFrom1To100
2{
3   public static void main(String[] args)
4   {
5      int maxNumber = 100;
6      boolean prime = true;
7      String primeNumbers = "";
8      for(int a = 1; a <= maxNumber; a++)
9      {
10         prime = checkPrime(a);
11         if(prime)
12         {
13            primeNumbers = primeNumbers + a + " ";
14         }
15      }
16      System.out.println("Display prime numbers from 1 to " + maxNumber + ": ");
17      System.out.println(primeNumbers);
18   }
19   public static boolean checkPrime(int number)
20   {
21      int remainder;
22      for(int a = 2; a <= number / 2; a++)
23      {
24         remainder = number % a;
25         // if remainder is equal to 0 then number is not prime
26         if(remainder == 0)
27         {
28            return false;
29         }
30      }
31      return true;
32   }
33}
queries leading to this page
prime number 1 to 50 program in java java program to display prime numbers from 1 to nprime number from 1 to 100 java codejava program to print prime numbers upto njava find prime numbers 1 100prime number in java from 1 to 100print prime numbers from 1 to 100 or notjava for loopjava code to find prime numbers between m and njava program to print first 50 prime numbersprint prime numbers upto n in javaget prime number till 10 5e5 jav a to print all prime numbers between 1 to 100 in javaprime numbers program in java 1 to 100 all sumprime number from 0 to 100 javaprime number program in java print 1 to 100prime number between 1 100000 loop javaprime numbers between 1 to 100 in javafind prime numbers till 1000 javareturn all prime numbers from 1 to 100print prime number program in javajava prime number allprime number from 1 to 50 in javahow many prime numbers between 1 and 100 in javajava program to print all prime numbers between 1 to 100to print all prime numbers between 1 to 100 in javaprime numbers between 1 to 50 using thread code with expaination in javaprint prime numbers list javajava program to print prime numbers from 2 to nprime numbers up to 100 javajava program to print 100 prime numbershow to find all prime nos from 100 to 200 in javaprime number upto 100 in javafind prime numbers from 1 to 100 in javaprime number program 1 100 in javawrite a program to generate prime number from 1 to 100 in javaprint 1 to 100 prime number in javaprime numbers from 1 to 100 in javaprime numbers between 1 to 50 using thread in javajava program to print prime numbers in a given rangewrite a program to print all prime numbers from 1 to 100 in javaformula to find prime numbers between 1 and 100 javaall prime numbers between 1 to 100 in java while loopcheck prime numbers in java between 1 and 100find prime number between 1 to 100 best javaprime number 1 to 50 in javaprime numbers program in java between 1 to 100 sumdisplay prime numbers from 1 to 100 in javaprime number from 1 to 100 javafind all prime numbers javawrite a program to find prime number in a given range in javahow to find prime numbers from 1 to 100 in javaprime numbers upto given number in javawap to print the first 10 prime numbers from 1 to 100 in javafind prime numbers between 0 to 100 javajava prime numbers from 1 to 100 gfgwrite a program to print prime numbers between 10 and 99 prime number till 10 5e12 javajava program to print 1 to 100 prime numbersprint prime numbers from 1 to 100 in javaprime number program java print 1 10023 29 java program to find the prime numbers between 1 to 100 prime number program in java up to 100prime number program from 1 to 50 in javaprogram to display prime numbers from 1 to 100how to prime numbers first 100 prime number javahow to calculate all the prime numbers in a for loop in javaprime number program in java between 1 to 100generate prime numbers in javajava code for prime number from 1 to 100write a program to print prime numbers from 1 to 100 in javahow to get the first 50 prime numbers in java using do looptotal number of prime numbers between 1 to 100 javato print all the prime numbers between 1 to 100 in javaprint prime numbers in java 1 to 10020 write a java program to print prime number from 2 to n java calculate prime number 1 1000000 5deasy way to print prime numbers in javacheck prime numbers 1 100 javajava prime number counterprime numbers 1 100 javaprime numbers between 1 and 100 in javaprime numbers from 1 to 50 javaprint prime numbersall the prime numbers till n 21 in javaprint the distance between the first 100 prime numbersprime numbers 1 to 100 in javaprint all prime numbers from x to 1 in javaprime number from 1 to 100 in javawap to print all prime numbers between 1 to 100 in javaprint prime numbers from 1 to 100 in java by checking consecutive numbersprint 1 100 prime numbers in javaprime number and 1 program in javaprime numbers from 1 to 100 javafind prime numbers between start and end javaprint prime numbers from 1 to 100 in continuous form javawrite a java program to find the prime numbers from 1 to 1001 to 100 prime numbers javahow to find out prime numbers in java from 1 to 100java program to display all prime numbers from 1 to nprint all prime numbers from 1 to n javaprint all the prime numbers from 0 to 1000 in javajava program to display prime numbers from 2 to 100get prime numbers and put into string in javaprime numbers between 1 to 10 in javaprint prime numbers from 1 to 100 in java with explanationprint 100 prime numbers in javajava program to print prime numbers 1 to 100java prime numbers from 1 to 100prime numbers between 1 to 100 codeprime number 1 to 1000 using java programprime number between 1 to 100 program in javaprint first 10 prime number from 1 to 100 in javaprint prime numbers in javaprime number between 1 to 100 in javaprime numbers from 1 to 20 in java all prime numbers between 1 to 100 in javaprint all prime numbers from 2 to n javahow to print prime numbers in javaprint 11 prime number per linejava program to print prime numbers between 10 and 99prime no 1 to 100 java1 100 prime numbers in javaget all prime numbers from 1 10000 and add to string in javajava print all prime numbers1 to 100 prime numbers java programprime number program in java print 1 to 20a prime number is a whole number greater than 1 that is divisible by 1 and itself only write a program that determines the first 50 prime numbers in javalist of prime numbers from 1 to 100 in javajava program to count prime numbers between 1 and 10000java code to generate prime numberprime numbers java 1 to 100how many prime numbers are there from 1 100 in javatotal number of prime numbers between 1 to 100 java programjava program to find prime number between 1 and 100create a program that displays prime numbers from 1 to 100 print prime numbers from 1 to 100 in java print hello for every set of 10prime numbers from 1 to 100 java programgenerate 100000 prime number in javaprint all prime numbers from 100 to 1 in javaprint prime numbers from 1 to 100 using java with explanationtotal number of prime numbers between 1 to 1500000 java using single loopwrite java code to find prime number between 1 to 100list of prime numbers 1 100 program logicprime numbers from 1 to 100 java code efficientlycreate a program that displays 5 digit prime numbers in javajava all prime numberprogram to find prime numbers java between a to bcreate a program that displays prime numbers from 1 to 100prime number from 1 to n in javafind prime number between 1 to 100 in javaprime numbers 1 to 50 program in javanumber of prime numbers till n javaprime number betwwen 1 to hundred javajava list of prime numberswrite a java program to find prime no between 1 to 1000prime numbers between 2 to 100 in javaprime numbers between 1 to 100 javajava program to loop for first 100000 positive prime numbersjava program to find sum of prime numbers between 1 and 1001 to 1000 prime numbers program in javaprime numbers 1 to 100 javaprint 1 to 100 prime numbers in javaall the prime number till 100 javaprime number in java 1 to 100prime no between 1 to 100 in javajava program to print prime numbers between 1 and 100how to find prime numbers between start and end javahow to find prime numbers from 1 to 100 in java using switchprime numbers till 100 codingprime numbers from 1 to 100 java program 2c separateddisplay all prime number and non prime number in javaprime or not 0 to 100 javajava program to display prime numbers between 1 to njava program to count prime numbers between 1 and 100java program get 50 prime numbersprime number 1 to 100 in javaget all prime numbers from 1 10000 in javaprime numbers from 1 to 100 in java best caseprint all prime numbers upto 100 in javaprimes between 1 and 100 in javajava calculate prime number 1 1000000find the prime numbers from 1 to 100 in javaprimesbetween javaprint prime number javawrite a program to display prime number between 1 to 100prime numbers in 100 javaprint prime number in javaprint list of prime numbers in java write logic to print prime numbers between 1 to 100 2ajava program to display prime numbers from 1 to 100java program to display prime numbers from 1 to 100