# Print prime numbers from 1 to 100 in java

In this program, we will print prime numbers from 1 to 100 in java.

A prime number is a number which has only two divisors 1 and itself. To check if the number is prime or not, we need to see if it has any other factors other than 1 or itself. If it has, then number is not prime else number is prime.

## Algorithm

• Iterate from 1 to 100.
• In each iteration, check is number is prime or not.
• If number is not divisible from 1 to sqrt(n) then number is not prime.
• If number is prime, print it.

### Here is java program to print prime numbers from 1 to 100.

When you will run above program, you will get below output:

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

That’s all about print prime numbers from 1 to 100 in java.

import_contacts

### You may also like: ## Related Posts

• 08 May

### Star Pattern programs in Java

Learn about how to print different star pattern in java.

• 17 April

### Convert Roman Number to Integer in Java

Learn about how to convert Roman number to Integer in java.

• 30 December

### Rock Paper Scissors Game in Java

Learn about how to implement Rock Paper Scissors game in java.

• 25 December

### Find automorphic number in java

Learn about how to find automorphic number in java using different methods

• 25 December

### Find nth prime number in java

Learn about how to find nth prime number in java.

• 06 October

### Implement distance formula in java

In this post, we will see how to implement distance formula between two points in java. Formula to find distance between two points ( x1, y1) and (x2 , y2) is d= sqrt( (x2-x1)^2+ (y2 – y1)^2) Here is simple program to calculate distance between two points in java. [crayon-63b2d7bc73737041988746/] Here we have used math.sqrt […]

## Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.