#### What are Prime Numbers?

Prime numbers are divisible only by the number 1 or itself. It is Whole numbers greater than 1.

For example:  2, 3, 5, 7 and 11 are the first few prime numbers.

#### How to display prime numbers between 1 to 100?

In this tutorial, We will learn how to get the prime numbers of any number. Here is a simple and well-commented example get the prime numbers.

Example:

``````
public class JavaApplication {

public static void main(String[] args) {

int i;
int num = 0;
int numCheck = 100; // number
boolean isPrime = true;

//Empty String

//Start loop 1 to numCheck
for (i = 1; i <= numCheck; i++) {
isPrime = CheckPrime(i);
if (isPrime) {
}
}
System.out.println("Prime numbers from 1 to " + numCheck + " are:");
// Print prime numbers from 1 to numCheck
}

public static boolean CheckPrime(int numberToCheck) {
int remainder;
for (int i = 2; i <= numberToCheck / 2; i++) {
remainder = numberToCheck % i;
//if remainder is 0 than number is not prime
if (remainder == 0) {
return false;
}
}
return true;

}

}
``````

Output:

 run: Prime numbers from 1 to 100 are: 1 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