How to find Prime Number in Java
Learn:
1. check the given number is prime or not.
2. print all the prime numbers upto a given a number
3. write different test cases
Code:
package Questions;
public class PrimeNumber {
//2 is the lowest prime number
//3
//num = 20
public static boolean isPrimeNumber(int num){
//edge/corner cases:
if(num<=1){
return false;
}
for(int i=2; i<num; i++){
if(num % i == 0){
return false;
}
}
return true;
}
public static void getPrimeNumbers(int num){
for(int i=2; i<=num; i++){
if(isPrimeNumber(i))
System.out.print(i + ” “);
}
}
public static void main(String[] args) {
System.out.println(“2 is prime number: “+ isPrimeNumber(2));
System.out.println(“3 is prime number: “+ isPrimeNumber(2));
System.out.println(“10 is prime number: “+ isPrimeNumber(10));
System.out.println(“17 is prime number: “+ isPrimeNumber(17));
System.out.println(“0 is prime number: “+ isPrimeNumber(0));
System.out.println(“1 is prime number: “+ isPrimeNumber(0));
System.out.println(“-3 is prime number: “+ isPrimeNumber(-3));
getPrimeNumbers(7);
getPrimeNumbers(13);
getPrimeNumbers(20);
}
}
Thanks for sharing this awesome post! This is really informative and I was searching for this. This'll be really helpful. Keep us updated with more such posts.
Excel Training in Chennai
Advanced Excel Training in Chennai
VMware Training in Chennai
VMware Course in Chennai
Manual Testing Training in Chennai
Manual Testing Courses in Chennai
Excel Training in Anna Nagar
Excel Training in T Nagar
I really learned a lot from your blog admin, keeps sharing more like this.
Data Science Course in Chennai
Data Science Training in Chennai
Machine Learning Course in Chennai
Machine Learning Training in Chennai
Azure Training in Chennai
Microsoft Azure Training in Chennai
Data Analytics Courses in Chennai
Data Science Training in Velachery
Data Science Training in Tambaram
Magnificent beat ! I wish to apprentice while you amend your web site, how could i subscribe for a blog web site? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear concept inbound marketing
The article is so informative. This is more helpful for our
selenium training in chennai
selenium online courses best selenium online training
selenium testing training
selenium classes
Thanks for sharing.
Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!
Web Designing Training Institute in Chennai | web design training class in chennai | web designing course in chennai with placement
Mobile Application Development Courses in chennai
Data Science Training in Chennai | Data Science courses in Chennai
Professional packers and movers in chennai | PDY Packers | Household Goods Shifting
Web Designing Training Institute in Chennai | Web Designing courses in Chennai
Google ads services | Google Ads Management agency
Web Designing Course in Chennai | Web Designing Training in Chennai
This is the first & best article to make me satisfied by presenting good content. I feel so happy and delighted.By Learn Digital Marketing Course Training in Chennai it will help to get Digital Marketing Course Training in Chennai.Learn Best Digital Marketing Course Training in Chennai's professional institute to get reputed job.
The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. IEEE final year projects on machine learning In case you will succeed, you have to begin building machine learning projects in the near future.
Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.
Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.
This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. ソンウルナンバー占いい
Wonderful blog! Thanks for sharing this valuable information
German Classes in Chennai
German Classes in Bangalore
German Classes in Coimbatore
German Classes in Madurai
German Language Course in Hyderabad
German Language Course in Bangalore
German Courses in Bangalore
German classes in marathahalli
Tally Course in Bangalore
Ielts coaching in bangalore