Java Program to list Prime numbers using for loop.1 min read

This post on Java Program to list Prime numbers using for loop is the same as the Java Program to check whether a number is prime or not.

The explanation is the same as checking for prime number, the only difference is that we set the last range number that is we take user input for the last number and check for prime number from 1 to that last number.

And if the boolean variable isPrime is true after checking for each number, it will print the number for each iteration.

Output:

Also, learn
Java Interview Programs