# Prime Number Program in Java | Using For Loop

prime number program in java:- we are going to start prime number program in java using for loop with example. So There is provided also composite numbers and prime numbers from 1 to 100.

After that in this section provide all example Prime number program

## Simple Prime Number Program in Java

``````import java.util.*;

{
public static void main(String args[])
{
int n, status = 1, num = 3, count, j;

Scanner in = new Scanner(System.in);
System.out.println("Enter prime numbers you want");
n = in.nextInt();

if (n >= 1)
{
System.out.println("First "+n+" prime numbers are:");
System.out.println(2);
}

for (count = 2; count <=n;)
{
for (j = 2; j <= Math.sqrt(num); j++)
{
if (num%j == 0)
{
status = 0;
break;
}
}
if (status != 0)
{
System.out.println(num);
count++;
}
status = 1;
num++;
}
}
}``````

## What are Prime Numbers

And In this article, we are going to finding Prime numbers right all the prime numbers. So till a particularly given number, there is no need to take all the numbers.

After that, you just find the square root of the given number. And if that square root is decimal take the next number.

As a result, check the desirably of all available numbers from 1 till that square root of the number. Therefore using the same principle.

We are going to find the prime number between 1 and 100 and method. After that We are going to use is called Eratosthenes Sieve so let me first.

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

## Prime Numbers from 1 to 100

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

### How to Find Prime Numbers ( prime number program in java )

In this paragraph, This method will start with from the first row and will go from left to right.

And check the desirably of all the numbers still only 10 why because the square root of 100 is 10. So 10*10 give us 100 since 10*10=100 which is the biggest number on this grade.

But if you can check desirably of all the numbers till 10 and strike of all the numbers. Therefor Which are desirable by the numbers till 10 and then will have a set of numbers. And create a prime number program in java

## Prime Number Composite Numbers ( Prime Number Program in Java )

As a result, Which is still meaning all of them will be prime numbers why because 10 get 10*10= 100 largest numbers in the grade. Also, learn advanced courses there are a lot of topic about Relational Algebra

So, there is no need to check the desirability but 11 12 13 and so on why because of 10*11=110. So, which is a number bigger than 100, and 10*13 is bigger than 100 so in this particular case.

Even more, Actually useless the check desirably of all the numbers by another number. Also, which is bigger than 10. So Will be starting pro cigar and then you will understand.

Why I say this and now let’s start the pro cigar. First will start the first row and each row will be gone from left to right.

The first will take the first row then will take the second row and since 10 is the first row. We are actually not supposed to go to the second row but to the cross-check a logic.

you will take the element of the second row also will take number 1 by 1 and then we will cross all the multiple. We will start from 1 and 1 is actually a special number it is neither classified as a prime number nor as a composite number.

## Simple Example to Find Prime Number

Prime Number Program in Java: Here, we are going to about 1 after this will go check from left to right and check for the still. There uncross how to number after this 2.

Therefore, 2 is a prime number and then what have to do I have the strike to all the numbers. Thus, the switch is the multiple numbers of 2 so all the numbers.

Therefore, which are numbers of 2 will be the even numbers on you can peacefully strike of alternate numbers.

Similarly, every second number of this number Therefor 2 is a prime number first number after 2. So, 3 and the second number after to 4 so 4 is multiple of 2 similar 6 is multiple numbers of 2.

Here, 8 is multiple numbers of 2 all the even numbers are multiples of 2. 12 is multiple numbers of 2,14,16,18 and 20 is multiple of 2.

After that, we can all these alternate columns then have even numbers. So, 3 is prime number All have to red color shade prime number. Thus All highlight number is prime numbers

HTML Syntax: first of all, we have to describe simple HTML tags with all information and also example create your simple page web learn to go to check.

Here, the latest News Naama goes to check world technical News on this website.

## Conclusion

As a result, we guide all main topic relative prime number program in java. So, if any topic and queries to relative this topic you can ask in the comments section. Also, you learn the most popular topic find Python Pass

1. You could definitely see your expertise in the work you write.
The world hopes for even more passionate writers like you who are not afraid to
mention how they believe. Always go after your heart.

2. I’m just writing to let you be aware of what a fabulous experience our girl enjoyed reading the blog. She learned a lot of pieces, with the inclusion of what it’s like to possess an amazing coaching spirit to let the others without problems understand a number of tricky subject matter. You actually surpassed our own expectations. Many thanks for coming up with such beneficial, healthy, educational and in addition cool thoughts on this topic to Ethel.

3. This is very attention-grabbing, You’re an overly skilled blogger.
Also, I’ve shared your web site in my social networks

4. You have remarked very interesting details! ps decent internet site.

5. If you are going for most excellent contents like myself,
simply pay a visit this web page all the time since it presents quality contents, thanks

individuals will go along with your views on this site.

7. Excellent post. I was checking continuously this blog and I am impressed!
Very helpful information particularly the last part 🙂 I care
for such info a lot. I was looking for this particular info for a long time.
Thank you and best of luck.

8. Thank you for the auspicious writeup. It in fact was a amusement account it.

By the way, how could we communicate?

Welcom… do you have any query ask every time

9. I intended to draft you one very little remark just to give many thanks again for your awesome thoughts you’ve discussed in this case. It’s so seriously generous with you to deliver without restraint exactly what a few individuals might have offered as an e book to end up making some dough for their own end, mostly considering the fact that you could have done it if you ever decided. Those smart ideas also served to be the great way to recognize that other people have a similar interest similar to my own to find out a great deal more pertaining to this problem. I am certain there are numerous more enjoyable occasions up front for folks who take a look at your site.

Welcome and thanks

10. I definitely wanted to post a brief remark in order to appreciate you for those marvelous techniques you are posting on this website. My long internet research has at the end of the day been rewarded with high-quality suggestions to write about with my good friends. I would mention that we readers actually are truly fortunate to be in a wonderful website with so many marvellous individuals with insightful advice. I feel quite grateful to have discovered the website page and look forward to many more excellent times reading here. Thanks again for everything.

11. Thanks so much for providing individuals with an exceptionally remarkable chance to read in detail from this website. It can be very excellent plus stuffed with fun for me personally and my office peers to visit your site at minimum thrice in a week to learn the new guidance you have. Of course, I’m just usually motivated with your remarkable tips and hints you serve. Certain two points in this post are in truth the most suitable we’ve had.

12. thanks for the post.

13. I am only writing to let you be aware of of the excellent encounter my cousin’s princess undergone viewing your web site. She came to understand several pieces, which include how it is like to possess an amazing giving style to have other people clearly grasp selected advanced topics. You undoubtedly exceeded our desires. Thank you for producing the effective, trusted, educational and in addition unique tips about the topic to Gloria.

14. A lot of thanks for each of your efforts on this blog. Gloria takes pleasure in managing investigations and it’s really simple to grasp why. My partner and i learn all regarding the lively means you provide informative information through your website and in addition recommend contribution from other individuals on that point then our own simple princess is in fact becoming educated a lot. Take advantage of the rest of the new year. You have been conducting a good job.

15. I would like to point out my respect for your kindness in support of those who absolutely need guidance on in this question. Your real dedication to passing the message all around had become exceedingly helpful and have in every case permitted some individuals much like me to reach their targets. Your amazing helpful report entails so much to me and still more to my fellow workers. Thanks a ton; from everyone of us.

16. quanto custa o remedio viagra tramadol and viagra interaction viagra 100 mg price viagra pfizer nebenwirkungen viagra generika kaufen express

17. My wife and i were very fulfilled when Albert managed to carry out his investigation from your precious recommendations he grabbed from your own blog. It is now and again perplexing just to choose to be giving out concepts which often men and women have been making money from. Therefore we know we need the website owner to be grateful to because of that. All the illustrations you’ve made, the easy website menu, the friendships you can help instill – it is many overwhelming, and it is aiding our son and us reason why the subject is cool, which is especially serious. Thanks for everything!

Welcome…Sir

18. What a stuff of un-ambiguity and preserveness of valuable familiarity about unpredicted emotions.|

19. Hi are using WordPress for your site platform? I’m new to the blog world but I’m trying to get started and set up my own. Do you require any html coding expertise to make your own blog? Any help would be greatly appreciated!|

20. This blog was… how do I say it? Relevant!! Finally I’ve found something that helped me. Thanks a lot!|

21. Hmm it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog writer but I’m still new to everything. Do you have any helpful hints for newbie blog writers? I’d genuinely appreciate it.|

22. This is very interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your great post. Also, I’ve shared your site in my social networks!|

## Related Post

### Should I Learn Html and CSS Before JavaScript

Let’s see all about in detail that should I learn HTML and CSS before javascript. Firstly, this is Html and CSS know some basic knowledge. Then you can better be understanding javascript and be doing work with it. Here, you can see about Html and CSS. Why we need and where are we need to […]

### How to Make Money As a Front End Developer

How to start earning money as a front end developer. Firstly, we explain the best ways that how to make money as a front end developer. So, I have listed some examples to make money if you have any front end skills. Also, discuss a few points about money as a web developer online. So, […]

### Row Vs Column : Cell Example of Table in Excel

We are going to explain row vs column when we the to arrange the data in a logical and concise manner. Hence, we know the main difference column vs row such as there are rows and columns for arranging the data only basic format. therefore, that data can be easily viewed from the table and […]