We'll first write a function to check whether a number is prime or not and then we loop through the first 100 numbers i.e. One of the most popular algorithms for generating prime is Sieve of Eratosthenes, which we have discussed earlier, but in this post, we will take a simpler approach. The key here is that you cannot use a library function which can simplify your job, you need to devise the algorithm for checking prime number by yourself. It's one of the most common coding exercises for programmers learning in Java, as it gives you an opportunity to learn more about the essential operators in Java Programming. Hello guys, today, I'll share with you a simple problem of writing a Java program to print prime numbers up to a given number like saying prime numbers from 1 to 100.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |