Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Java Program to print Prime numbers in Java


How to Print Prime Numbers in Java or how to check if a Number is prime or not is classical Java programming questions, mostly taught in Java programming courses. A number is called prime number if its not divisible by any number other than 1 or itself and you can use this logic to check whether a number is prime or not. This program is slightly difficult than printing even or odd number which are relatively easier Java exercises. This Simple Java program print prime number starting from 1 to 100 or any specified number. It also has a method which checks if a number is prime or not.



Here is complete sample code example to print prime numbers from 1 to any specified number. This Java program can also check if a number is prime or not as prime number checking logic is encapsulated in isPrime(int number) method.


http://codesforprogrammers.blogspot.com/feeds/posts/default?alt=rss


This post first appeared on Codes For Programmers(C4P), please read the originial post: here

Share the post

Java Program to print Prime numbers in Java

×

Subscribe to Codes For Programmers(c4p)

Get updates delivered right to your inbox!

Thank you for your subscription

×